Skip to content

Commit 883af14

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "26 fixes" * emailed patches from Andrew Morton <[email protected]>: (26 commits) MAINTAINERS: add Dan Streetman to zbud maintainers MAINTAINERS: add Dan Streetman to zswap maintainers mm: do not export ioremap_page_range symbol for external module mn10300: fix build error of missing fpu_save() romfs: use different way to generate fsid for BLOCK or MTD frv: add missing atomic64 operations mm, page_alloc: fix premature OOM when racing with cpuset mems update mm, page_alloc: move cpuset seqcount checking to slowpath mm, page_alloc: fix fast-path race with cpuset update or removal mm, page_alloc: fix check for NULL preferred_zone kernel/panic.c: add missing \n fbdev: color map copying bounds checking frv: add atomic64_add_unless() mm/mempolicy.c: do not put mempolicy before using its nodemask radix-tree: fix private list warnings Documentation/filesystems/proc.txt: add VmPin mm, memcg: do not retry precharge charges proc: add a schedule point in proc_pid_readdir() mm: alloc_contig: re-allow CMA to compact FS pages mm/slub.c: trace free objects at KERN_INFO ...
2 parents 0263d4e + aab4545 commit 883af14

File tree

28 files changed

+237
-78
lines changed

28 files changed

+237
-78
lines changed

Documentation/filesystems/proc.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ asynchronous manner and the value may not be very precise. To see a precise
212212
snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
213213
It's slow but very precise.
214214

215-
Table 1-2: Contents of the status files (as of 4.1)
215+
Table 1-2: Contents of the status files (as of 4.8)
216216
..............................................................................
217217
Field Content
218218
Name filename of the executable
219+
Umask file mode creation mask
219220
State state (R is running, S is sleeping, D is sleeping
220221
in an uninterruptible wait, Z is zombie,
221222
T is traced or stopped)
@@ -226,7 +227,6 @@ Table 1-2: Contents of the status files (as of 4.1)
226227
TracerPid PID of process tracing this process (0 if not)
227228
Uid Real, effective, saved set, and file system UIDs
228229
Gid Real, effective, saved set, and file system GIDs
229-
Umask file mode creation mask
230230
FDSize number of file descriptor slots currently allocated
231231
Groups supplementary group list
232232
NStgid descendant namespace thread group ID hierarchy
@@ -236,6 +236,7 @@ Table 1-2: Contents of the status files (as of 4.1)
236236
VmPeak peak virtual memory size
237237
VmSize total program size
238238
VmLck locked memory size
239+
VmPin pinned memory size
239240
VmHWM peak resident set size ("high water mark")
240241
VmRSS size of memory portions. It contains the three
241242
following parts (VmRSS = RssAnon + RssFile + RssShmem)

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13625,6 +13625,7 @@ F: drivers/net/hamradio/z8530.h
1362513625

1362613626
ZBUD COMPRESSED PAGE ALLOCATOR
1362713627
M: Seth Jennings <[email protected]>
13628+
M: Dan Streetman <[email protected]>
1362813629
1362913630
S: Maintained
1363013631
F: mm/zbud.c
@@ -13680,6 +13681,7 @@ F: Documentation/vm/zsmalloc.txt
1368013681

1368113682
ZSWAP COMPRESSED SWAP CACHING
1368213683
M: Seth Jennings <[email protected]>
13684+
M: Dan Streetman <[email protected]>
1368313685
1368413686
S: Maintained
1368513687
F: mm/zswap.c

arch/frv/include/asm/atomic.h

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static inline void atomic64_dec(atomic64_t *v)
139139
#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0)
140140
#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
141141
#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0)
142-
142+
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
143143

144144
#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new))
145145
#define atomic_xchg(v, new) (xchg(&(v)->counter, new))
@@ -161,6 +161,39 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
161161
return c;
162162
}
163163

164+
static inline int atomic64_add_unless(atomic64_t *v, long long i, long long u)
165+
{
166+
long long c, old;
167+
168+
c = atomic64_read(v);
169+
for (;;) {
170+
if (unlikely(c == u))
171+
break;
172+
old = atomic64_cmpxchg(v, c, c + i);
173+
if (likely(old == c))
174+
break;
175+
c = old;
176+
}
177+
return c != u;
178+
}
179+
180+
static inline long long atomic64_dec_if_positive(atomic64_t *v)
181+
{
182+
long long c, old, dec;
183+
184+
c = atomic64_read(v);
185+
for (;;) {
186+
dec = c - 1;
187+
if (unlikely(dec < 0))
188+
break;
189+
old = atomic64_cmpxchg((v), c, dec);
190+
if (likely(old == c))
191+
break;
192+
c = old;
193+
}
194+
return dec;
195+
}
196+
164197
#define ATOMIC_OP(op) \
165198
static inline int atomic_fetch_##op(int i, atomic_t *v) \
166199
{ \

arch/mn10300/include/asm/switch_to.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
struct task_struct;
1717
struct thread_struct;
1818

19-
#if !defined(CONFIG_LAZY_SAVE_FPU)
19+
#if defined(CONFIG_FPU) && !defined(CONFIG_LAZY_SAVE_FPU)
2020
struct fpu_state_struct;
2121
extern asmlinkage void fpu_save(struct fpu_state_struct *);
2222
#define switch_fpu(prev, next) \

drivers/base/memory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,14 @@ static ssize_t show_valid_zones(struct device *dev,
408408
sprintf(buf, "%s", zone->name);
409409

410410
/* MMOP_ONLINE_KERNEL */
411-
zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_NORMAL);
411+
zone_can_shift(start_pfn, nr_pages, ZONE_NORMAL, &zone_shift);
412412
if (zone_shift) {
413413
strcat(buf, " ");
414414
strcat(buf, (zone + zone_shift)->name);
415415
}
416416

417417
/* MMOP_ONLINE_MOVABLE */
418-
zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_MOVABLE);
418+
zone_can_shift(start_pfn, nr_pages, ZONE_MOVABLE, &zone_shift);
419419
if (zone_shift) {
420420
strcat(buf, " ");
421421
strcat(buf, (zone + zone_shift)->name);

drivers/memstick/core/memstick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static int h_memstick_read_dev_id(struct memstick_dev *card,
330330
struct ms_id_register id_reg;
331331

332332
if (!(*mrq)) {
333-
memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL,
333+
memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, &id_reg,
334334
sizeof(struct ms_id_register));
335335
*mrq = &card->current_mrq;
336336
return 0;

drivers/video/fbdev/core/fbcmap.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,18 @@ void fb_dealloc_cmap(struct fb_cmap *cmap)
163163

164164
int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to)
165165
{
166-
int tooff = 0, fromoff = 0;
167-
int size;
166+
unsigned int tooff = 0, fromoff = 0;
167+
size_t size;
168168

169169
if (to->start > from->start)
170170
fromoff = to->start - from->start;
171171
else
172172
tooff = from->start - to->start;
173-
size = to->len - tooff;
174-
if (size > (int) (from->len - fromoff))
175-
size = from->len - fromoff;
176-
if (size <= 0)
173+
if (fromoff >= from->len || tooff >= to->len)
174+
return -EINVAL;
175+
176+
size = min_t(size_t, to->len - tooff, from->len - fromoff);
177+
if (size == 0)
177178
return -EINVAL;
178179
size *= sizeof(u16);
179180

@@ -187,17 +188,18 @@ int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to)
187188

188189
int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to)
189190
{
190-
int tooff = 0, fromoff = 0;
191-
int size;
191+
unsigned int tooff = 0, fromoff = 0;
192+
size_t size;
192193

193194
if (to->start > from->start)
194195
fromoff = to->start - from->start;
195196
else
196197
tooff = from->start - to->start;
197-
size = to->len - tooff;
198-
if (size > (int) (from->len - fromoff))
199-
size = from->len - fromoff;
200-
if (size <= 0)
198+
if (fromoff >= from->len || tooff >= to->len)
199+
return -EINVAL;
200+
201+
size = min_t(size_t, to->len - tooff, from->len - fromoff);
202+
if (size == 0)
201203
return -EINVAL;
202204
size *= sizeof(u16);
203205

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config FS_DAX
3838
bool "Direct Access (DAX) support"
3939
depends on MMU
4040
depends on !(ARM || MIPS || SPARC)
41+
select FS_IOMAP
4142
help
4243
Direct Access (DAX) can be used on memory-backed block devices.
4344
If the block device supports DAX and the filesystem supports DAX,

fs/dax.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ int __dax_zero_page_range(struct block_device *bdev, sector_t sector,
990990
}
991991
EXPORT_SYMBOL_GPL(__dax_zero_page_range);
992992

993-
#ifdef CONFIG_FS_IOMAP
994993
static sector_t dax_iomap_sector(struct iomap *iomap, loff_t pos)
995994
{
996995
return iomap->blkno + (((pos & PAGE_MASK) - iomap->offset) >> 9);
@@ -1428,4 +1427,3 @@ int dax_iomap_pmd_fault(struct vm_area_struct *vma, unsigned long address,
14281427
}
14291428
EXPORT_SYMBOL_GPL(dax_iomap_pmd_fault);
14301429
#endif /* CONFIG_FS_DAX_PMD */
1431-
#endif /* CONFIG_FS_IOMAP */

fs/ext2/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
config EXT2_FS
22
tristate "Second extended fs support"
3-
select FS_IOMAP if FS_DAX
43
help
54
Ext2 is a standard Linux file system for hard disks.
65

fs/ext4/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ config EXT4_FS
3737
select CRC16
3838
select CRYPTO
3939
select CRYPTO_CRC32C
40-
select FS_IOMAP if FS_DAX
4140
help
4241
This is the next generation of the ext3 filesystem.
4342

fs/proc/base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,8 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
31793179
iter.tgid += 1, iter = next_tgid(ns, iter)) {
31803180
char name[PROC_NUMBUF];
31813181
int len;
3182+
3183+
cond_resched();
31823184
if (!has_pid_permissions(ns, iter.task, 2))
31833185
continue;
31843186

fs/romfs/super.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include <linux/highmem.h>
7575
#include <linux/pagemap.h>
7676
#include <linux/uaccess.h>
77+
#include <linux/major.h>
7778
#include "internal.h"
7879

7980
static struct kmem_cache *romfs_inode_cachep;
@@ -416,7 +417,22 @@ static void romfs_destroy_inode(struct inode *inode)
416417
static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
417418
{
418419
struct super_block *sb = dentry->d_sb;
419-
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
420+
u64 id = 0;
421+
422+
/* When calling huge_encode_dev(),
423+
* use sb->s_bdev->bd_dev when,
424+
* - CONFIG_ROMFS_ON_BLOCK defined
425+
* use sb->s_dev when,
426+
* - CONFIG_ROMFS_ON_BLOCK undefined and
427+
* - CONFIG_ROMFS_ON_MTD defined
428+
* leave id as 0 when,
429+
* - CONFIG_ROMFS_ON_BLOCK undefined and
430+
* - CONFIG_ROMFS_ON_MTD undefined
431+
*/
432+
if (sb->s_bdev)
433+
id = huge_encode_dev(sb->s_bdev->bd_dev);
434+
else if (sb->s_dev)
435+
id = huge_encode_dev(sb->s_dev);
420436

421437
buf->f_type = ROMFS_MAGIC;
422438
buf->f_namelen = ROMFS_MAXFN;
@@ -489,6 +505,11 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
489505
sb->s_flags |= MS_RDONLY | MS_NOATIME;
490506
sb->s_op = &romfs_super_ops;
491507

508+
#ifdef CONFIG_ROMFS_ON_MTD
509+
/* Use same dev ID from the underlying mtdblock device */
510+
if (sb->s_mtd)
511+
sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, sb->s_mtd->index);
512+
#endif
492513
/* read the image superblock and check it */
493514
rsb = kmalloc(512, GFP_KERNEL);
494515
if (!rsb)

fs/userfaultfd.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct userfaultfd_wait_queue {
6363
struct uffd_msg msg;
6464
wait_queue_t wq;
6565
struct userfaultfd_ctx *ctx;
66+
bool waken;
6667
};
6768

6869
struct userfaultfd_wake_range {
@@ -86,6 +87,12 @@ static int userfaultfd_wake_function(wait_queue_t *wq, unsigned mode,
8687
if (len && (start > uwq->msg.arg.pagefault.address ||
8788
start + len <= uwq->msg.arg.pagefault.address))
8889
goto out;
90+
WRITE_ONCE(uwq->waken, true);
91+
/*
92+
* The implicit smp_mb__before_spinlock in try_to_wake_up()
93+
* renders uwq->waken visible to other CPUs before the task is
94+
* waken.
95+
*/
8996
ret = wake_up_state(wq->private, mode);
9097
if (ret)
9198
/*
@@ -264,6 +271,7 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
264271
struct userfaultfd_wait_queue uwq;
265272
int ret;
266273
bool must_wait, return_to_userland;
274+
long blocking_state;
267275

268276
BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
269277

@@ -334,10 +342,13 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
334342
uwq.wq.private = current;
335343
uwq.msg = userfault_msg(vmf->address, vmf->flags, reason);
336344
uwq.ctx = ctx;
345+
uwq.waken = false;
337346

338347
return_to_userland =
339348
(vmf->flags & (FAULT_FLAG_USER|FAULT_FLAG_KILLABLE)) ==
340349
(FAULT_FLAG_USER|FAULT_FLAG_KILLABLE);
350+
blocking_state = return_to_userland ? TASK_INTERRUPTIBLE :
351+
TASK_KILLABLE;
341352

342353
spin_lock(&ctx->fault_pending_wqh.lock);
343354
/*
@@ -350,8 +361,7 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
350361
* following the spin_unlock to happen before the list_add in
351362
* __add_wait_queue.
352363
*/
353-
set_current_state(return_to_userland ? TASK_INTERRUPTIBLE :
354-
TASK_KILLABLE);
364+
set_current_state(blocking_state);
355365
spin_unlock(&ctx->fault_pending_wqh.lock);
356366

357367
must_wait = userfaultfd_must_wait(ctx, vmf->address, vmf->flags,
@@ -364,6 +374,29 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
364374
wake_up_poll(&ctx->fd_wqh, POLLIN);
365375
schedule();
366376
ret |= VM_FAULT_MAJOR;
377+
378+
/*
379+
* False wakeups can orginate even from rwsem before
380+
* up_read() however userfaults will wait either for a
381+
* targeted wakeup on the specific uwq waitqueue from
382+
* wake_userfault() or for signals or for uffd
383+
* release.
384+
*/
385+
while (!READ_ONCE(uwq.waken)) {
386+
/*
387+
* This needs the full smp_store_mb()
388+
* guarantee as the state write must be
389+
* visible to other CPUs before reading
390+
* uwq.waken from other CPUs.
391+
*/
392+
set_current_state(blocking_state);
393+
if (READ_ONCE(uwq.waken) ||
394+
READ_ONCE(ctx->released) ||
395+
(return_to_userland ? signal_pending(current) :
396+
fatal_signal_pending(current)))
397+
break;
398+
schedule();
399+
}
367400
}
368401

369402
__set_current_state(TASK_RUNNING);

include/linux/memory_hotplug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms,
284284
unsigned long map_offset);
285285
extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
286286
unsigned long pnum);
287-
extern int zone_can_shift(unsigned long pfn, unsigned long nr_pages,
288-
enum zone_type target);
287+
extern bool zone_can_shift(unsigned long pfn, unsigned long nr_pages,
288+
enum zone_type target, int *zone_shift);
289289

290290
#endif /* __LINUX_MEMORY_HOTPLUG_H */

include/linux/mmzone.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,12 +972,16 @@ static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z,
972972
* @zonelist - The zonelist to search for a suitable zone
973973
* @highest_zoneidx - The zone index of the highest zone to return
974974
* @nodes - An optional nodemask to filter the zonelist with
975-
* @zone - The first suitable zone found is returned via this parameter
975+
* @return - Zoneref pointer for the first suitable zone found (see below)
976976
*
977977
* This function returns the first zone at or below a given zone index that is
978978
* within the allowed nodemask. The zoneref returned is a cursor that can be
979979
* used to iterate the zonelist with next_zones_zonelist by advancing it by
980980
* one before calling.
981+
*
982+
* When no eligible zone is found, zoneref->zone is NULL (zoneref itself is
983+
* never NULL). This may happen either genuinely, or due to concurrent nodemask
984+
* update due to cpuset modification.
981985
*/
982986
static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
983987
enum zone_type highest_zoneidx,

include/linux/nmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern int watchdog_user_enabled;
110110
extern int watchdog_thresh;
111111
extern unsigned long watchdog_enabled;
112112
extern unsigned long *watchdog_cpumask_bits;
113+
extern atomic_t watchdog_park_in_progress;
113114
#ifdef CONFIG_SMP
114115
extern int sysctl_softlockup_all_cpu_backtrace;
115116
extern int sysctl_hardlockup_all_cpu_backtrace;

kernel/panic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void panic(const char *fmt, ...)
249249
* Delay timeout seconds before rebooting the machine.
250250
* We can't use the "normal" timers since we just panicked.
251251
*/
252-
pr_emerg("Rebooting in %d seconds..", panic_timeout);
252+
pr_emerg("Rebooting in %d seconds..\n", panic_timeout);
253253

254254
for (i = 0; i < panic_timeout * 1000; i += PANIC_TIMER_STEP) {
255255
touch_nmi_watchdog();

0 commit comments

Comments
 (0)