Skip to content

Commit 7ce32ac

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "24 patches, based on 4a09d38. Subsystems affected by this patch series: mm (thp, vmalloc, hugetlb, memory-failure, and pagealloc), nilfs2, kthread, MAINTAINERS, and mailmap" * emailed patches from Andrew Morton <[email protected]>: (24 commits) mailmap: add Marek's other e-mail address and identity without diacritics MAINTAINERS: fix Marek's identity again mm/page_alloc: do bulk array bounds check after checking populated elements mm/page_alloc: __alloc_pages_bulk(): do bounds check before accessing array mm/hwpoison: do not lock page again when me_huge_page() successfully recovers mm,hwpoison: return -EHWPOISON to denote that the page has already been poisoned mm/memory-failure: use a mutex to avoid memory_failure() races mm, futex: fix shared futex pgoff on shmem huge page kthread: prevent deadlock when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync() kthread_worker: split code for canceling the delayed work timer mm/vmalloc: unbreak kasan vmalloc support KVM: s390: prepare for hugepage vmalloc mm/vmalloc: add vmalloc_no_huge nilfs2: fix memory leak in nilfs_sysfs_delete_device_group mm/thp: another PVMW_SYNC fix in page_vma_mapped_walk() mm/thp: fix page_vma_mapped_walk() if THP mapped by ptes mm: page_vma_mapped_walk(): get vma_address_end() earlier mm: page_vma_mapped_walk(): use goto instead of while (1) mm: page_vma_mapped_walk(): add a level of indentation mm: page_vma_mapped_walk(): crossing page table boundary ...
2 parents 808e9df + 72a461a commit 7ce32ac

File tree

14 files changed

+258
-160
lines changed

14 files changed

+258
-160
lines changed

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ Manivannan Sadhasivam <[email protected]> <[email protected]>
212212
Manivannan Sadhasivam <[email protected]> <[email protected]>
213213
214214
215+
216+
Marek Behún <[email protected]> Marek Behun <[email protected]>
215217
Mark Brown <[email protected]>
216218
217219

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ F: drivers/pinctrl/pinctrl-gemini.c
18161816
F: drivers/rtc/rtc-ftrtc010.c
18171817

18181818
ARM/CZ.NIC TURRIS SUPPORT
1819-
M: Marek Behun <[email protected]>
1819+
M: Marek Behún <[email protected]>
18201820
S: Maintained
18211821
W: https://www.turris.cz/
18221822
F: Documentation/ABI/testing/debugfs-moxtet
@@ -10945,7 +10945,7 @@ F: include/linux/mv643xx.h
1094510945

1094610946
MARVELL MV88X3310 PHY DRIVER
1094710947
M: Russell King <[email protected]>
10948-
M: Marek Behun <[email protected]>
10948+
M: Marek Behún <[email protected]>
1094910949
1095010950
S: Maintained
1095110951
F: drivers/net/phy/marvell10g.c

arch/s390/kvm/pv.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
140140
/* Allocate variable storage */
141141
vlen = ALIGN(virt * ((npages * PAGE_SIZE) / HPAGE_SIZE), PAGE_SIZE);
142142
vlen += uv_info.guest_virt_base_stor_len;
143-
kvm->arch.pv.stor_var = vzalloc(vlen);
143+
/*
144+
* The Create Secure Configuration Ultravisor Call does not support
145+
* using large pages for the virtual memory area.
146+
* This is a hardware limitation.
147+
*/
148+
kvm->arch.pv.stor_var = vmalloc_no_huge(vlen);
144149
if (!kvm->arch.pv.stor_var)
145150
goto out_err;
146151
return 0;

fs/nilfs2/sysfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs)
10531053
nilfs_sysfs_delete_superblock_group(nilfs);
10541054
nilfs_sysfs_delete_segctor_group(nilfs);
10551055
kobject_del(&nilfs->ns_dev_kobj);
1056+
kobject_put(&nilfs->ns_dev_kobj);
10561057
kfree(nilfs->ns_dev_subgroups);
10571058
}
10581059

include/linux/hugetlb.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -741,17 +741,6 @@ static inline int hstate_index(struct hstate *h)
741741
return h - hstates;
742742
}
743743

744-
pgoff_t __basepage_index(struct page *page);
745-
746-
/* Return page->index in PAGE_SIZE units */
747-
static inline pgoff_t basepage_index(struct page *page)
748-
{
749-
if (!PageCompound(page))
750-
return page->index;
751-
752-
return __basepage_index(page);
753-
}
754-
755744
extern int dissolve_free_huge_page(struct page *page);
756745
extern int dissolve_free_huge_pages(unsigned long start_pfn,
757746
unsigned long end_pfn);
@@ -988,11 +977,6 @@ static inline int hstate_index(struct hstate *h)
988977
return 0;
989978
}
990979

991-
static inline pgoff_t basepage_index(struct page *page)
992-
{
993-
return page->index;
994-
}
995-
996980
static inline int dissolve_free_huge_page(struct page *page)
997981
{
998982
return 0;

include/linux/pagemap.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
516516
}
517517

518518
/*
519-
* Get index of the page with in radix-tree
519+
* Get index of the page within radix-tree (but not for hugetlb pages).
520520
* (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
521521
*/
522522
static inline pgoff_t page_to_index(struct page *page)
@@ -535,15 +535,16 @@ static inline pgoff_t page_to_index(struct page *page)
535535
return pgoff;
536536
}
537537

538+
extern pgoff_t hugetlb_basepage_index(struct page *page);
539+
538540
/*
539-
* Get the offset in PAGE_SIZE.
540-
* (TODO: hugepage should have ->index in PAGE_SIZE)
541+
* Get the offset in PAGE_SIZE (even for hugetlb pages).
542+
* (TODO: hugetlb pages should have ->index in PAGE_SIZE)
541543
*/
542544
static inline pgoff_t page_to_pgoff(struct page *page)
543545
{
544-
if (unlikely(PageHeadHuge(page)))
545-
return page->index << compound_order(page);
546-
546+
if (unlikely(PageHuge(page)))
547+
return hugetlb_basepage_index(page);
547548
return page_to_index(page);
548549
}
549550

include/linux/vmalloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
135135
const void *caller);
136136
void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask,
137137
int node, const void *caller);
138+
void *vmalloc_no_huge(unsigned long size);
138139

139140
extern void vfree(const void *addr);
140141
extern void vfree_atomic(const void *addr);

kernel/futex.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <linux/jhash.h>
3636
#include <linux/pagemap.h>
3737
#include <linux/syscalls.h>
38-
#include <linux/hugetlb.h>
3938
#include <linux/freezer.h>
4039
#include <linux/memblock.h>
4140
#include <linux/fault-inject.h>
@@ -650,7 +649,7 @@ static int get_futex_key(u32 __user *uaddr, bool fshared, union futex_key *key,
650649

651650
key->both.offset |= FUT_OFF_INODE; /* inode-based key */
652651
key->shared.i_seq = get_inode_sequence_number(inode);
653-
key->shared.pgoff = basepage_index(tail);
652+
key->shared.pgoff = page_to_pgoff(tail);
654653
rcu_read_unlock();
655654
}
656655

kernel/kthread.c

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,37 +1093,47 @@ void kthread_flush_work(struct kthread_work *work)
10931093
EXPORT_SYMBOL_GPL(kthread_flush_work);
10941094

10951095
/*
1096-
* This function removes the work from the worker queue. Also it makes sure
1097-
* that it won't get queued later via the delayed work's timer.
1096+
* Make sure that the timer is neither set nor running and could
1097+
* not manipulate the work list_head any longer.
1098+
*
1099+
* The function is called under worker->lock. The lock is temporary
1100+
* released but the timer can't be set again in the meantime.
1101+
*/
1102+
static void kthread_cancel_delayed_work_timer(struct kthread_work *work,
1103+
unsigned long *flags)
1104+
{
1105+
struct kthread_delayed_work *dwork =
1106+
container_of(work, struct kthread_delayed_work, work);
1107+
struct kthread_worker *worker = work->worker;
1108+
1109+
/*
1110+
* del_timer_sync() must be called to make sure that the timer
1111+
* callback is not running. The lock must be temporary released
1112+
* to avoid a deadlock with the callback. In the meantime,
1113+
* any queuing is blocked by setting the canceling counter.
1114+
*/
1115+
work->canceling++;
1116+
raw_spin_unlock_irqrestore(&worker->lock, *flags);
1117+
del_timer_sync(&dwork->timer);
1118+
raw_spin_lock_irqsave(&worker->lock, *flags);
1119+
work->canceling--;
1120+
}
1121+
1122+
/*
1123+
* This function removes the work from the worker queue.
1124+
*
1125+
* It is called under worker->lock. The caller must make sure that
1126+
* the timer used by delayed work is not running, e.g. by calling
1127+
* kthread_cancel_delayed_work_timer().
10981128
*
10991129
* The work might still be in use when this function finishes. See the
11001130
* current_work proceed by the worker.
11011131
*
11021132
* Return: %true if @work was pending and successfully canceled,
11031133
* %false if @work was not pending
11041134
*/
1105-
static bool __kthread_cancel_work(struct kthread_work *work, bool is_dwork,
1106-
unsigned long *flags)
1135+
static bool __kthread_cancel_work(struct kthread_work *work)
11071136
{
1108-
/* Try to cancel the timer if exists. */
1109-
if (is_dwork) {
1110-
struct kthread_delayed_work *dwork =
1111-
container_of(work, struct kthread_delayed_work, work);
1112-
struct kthread_worker *worker = work->worker;
1113-
1114-
/*
1115-
* del_timer_sync() must be called to make sure that the timer
1116-
* callback is not running. The lock must be temporary released
1117-
* to avoid a deadlock with the callback. In the meantime,
1118-
* any queuing is blocked by setting the canceling counter.
1119-
*/
1120-
work->canceling++;
1121-
raw_spin_unlock_irqrestore(&worker->lock, *flags);
1122-
del_timer_sync(&dwork->timer);
1123-
raw_spin_lock_irqsave(&worker->lock, *flags);
1124-
work->canceling--;
1125-
}
1126-
11271137
/*
11281138
* Try to remove the work from a worker list. It might either
11291139
* be from worker->work_list or from worker->delayed_work_list.
@@ -1176,11 +1186,23 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,
11761186
/* Work must not be used with >1 worker, see kthread_queue_work() */
11771187
WARN_ON_ONCE(work->worker != worker);
11781188

1179-
/* Do not fight with another command that is canceling this work. */
1189+
/*
1190+
* Temporary cancel the work but do not fight with another command
1191+
* that is canceling the work as well.
1192+
*
1193+
* It is a bit tricky because of possible races with another
1194+
* mod_delayed_work() and cancel_delayed_work() callers.
1195+
*
1196+
* The timer must be canceled first because worker->lock is released
1197+
* when doing so. But the work can be removed from the queue (list)
1198+
* only when it can be queued again so that the return value can
1199+
* be used for reference counting.
1200+
*/
1201+
kthread_cancel_delayed_work_timer(work, &flags);
11801202
if (work->canceling)
11811203
goto out;
1204+
ret = __kthread_cancel_work(work);
11821205

1183-
ret = __kthread_cancel_work(work, true, &flags);
11841206
fast_queue:
11851207
__kthread_queue_delayed_work(worker, dwork, delay);
11861208
out:
@@ -1202,7 +1224,10 @@ static bool __kthread_cancel_work_sync(struct kthread_work *work, bool is_dwork)
12021224
/* Work must not be used with >1 worker, see kthread_queue_work(). */
12031225
WARN_ON_ONCE(work->worker != worker);
12041226

1205-
ret = __kthread_cancel_work(work, is_dwork, &flags);
1227+
if (is_dwork)
1228+
kthread_cancel_delayed_work_timer(work, &flags);
1229+
1230+
ret = __kthread_cancel_work(work);
12061231

12071232
if (worker->current_work != work)
12081233
goto out_fast;

mm/hugetlb.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,15 +1588,12 @@ struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage)
15881588
return NULL;
15891589
}
15901590

1591-
pgoff_t __basepage_index(struct page *page)
1591+
pgoff_t hugetlb_basepage_index(struct page *page)
15921592
{
15931593
struct page *page_head = compound_head(page);
15941594
pgoff_t index = page_index(page_head);
15951595
unsigned long compound_idx;
15961596

1597-
if (!PageHuge(page_head))
1598-
return page_index(page);
1599-
16001597
if (compound_order(page_head) >= MAX_ORDER)
16011598
compound_idx = page_to_pfn(page) - page_to_pfn(page_head);
16021599
else

0 commit comments

Comments
 (0)