Skip to content

Commit ce94493

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "9 fixes" * emailed patches from Andrew Morton <[email protected]>: fs/proc/proc_sysctl.c: Fix a NULL pointer dereference mm/page_alloc.c: fix never set ALLOC_NOFRAGMENT flag mm/page_alloc.c: avoid potential NULL pointer dereference mm, page_alloc: always use a captured page regardless of compaction result mm: do not boost watermarks to avoid fragmentation for the DISCONTIG memory model lib/test_vmalloc.c: do not create cpumask_t variable on stack lib/Kconfig.debug: fix build error without CONFIG_BLOCK zram: pass down the bvec we need to read into in the work struct mm/memory_hotplug.c: drop memory device reference after find_memory_block()
2 parents 857e17c + 8918955 commit ce94493

File tree

7 files changed

+39
-23
lines changed

7 files changed

+39
-23
lines changed

Documentation/sysctl/vm.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -866,14 +866,14 @@ The intent is that compaction has less work to do in the future and to
866866
increase the success rate of future high-order allocations such as SLUB
867867
allocations, THP and hugetlbfs pages.
868868

869-
To make it sensible with respect to the watermark_scale_factor parameter,
870-
the unit is in fractions of 10,000. The default value of 15,000 means
871-
that up to 150% of the high watermark will be reclaimed in the event of
872-
a pageblock being mixed due to fragmentation. The level of reclaim is
873-
determined by the number of fragmentation events that occurred in the
874-
recent past. If this value is smaller than a pageblock then a pageblocks
875-
worth of pages will be reclaimed (e.g. 2MB on 64-bit x86). A boost factor
876-
of 0 will disable the feature.
869+
To make it sensible with respect to the watermark_scale_factor
870+
parameter, the unit is in fractions of 10,000. The default value of
871+
15,000 on !DISCONTIGMEM configurations means that up to 150% of the high
872+
watermark will be reclaimed in the event of a pageblock being mixed due
873+
to fragmentation. The level of reclaim is determined by the number of
874+
fragmentation events that occurred in the recent past. If this value is
875+
smaller than a pageblock then a pageblocks worth of pages will be reclaimed
876+
(e.g. 2MB on 64-bit x86). A boost factor of 0 will disable the feature.
877877

878878
=============================================================
879879

drivers/block/zram/zram_drv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,18 +774,18 @@ struct zram_work {
774774
struct zram *zram;
775775
unsigned long entry;
776776
struct bio *bio;
777+
struct bio_vec bvec;
777778
};
778779

779780
#if PAGE_SIZE != 4096
780781
static void zram_sync_read(struct work_struct *work)
781782
{
782-
struct bio_vec bvec;
783783
struct zram_work *zw = container_of(work, struct zram_work, work);
784784
struct zram *zram = zw->zram;
785785
unsigned long entry = zw->entry;
786786
struct bio *bio = zw->bio;
787787

788-
read_from_bdev_async(zram, &bvec, entry, bio);
788+
read_from_bdev_async(zram, &zw->bvec, entry, bio);
789789
}
790790

791791
/*
@@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zram *zram, struct bio_vec *bvec,
798798
{
799799
struct zram_work work;
800800

801+
work.bvec = *bvec;
801802
work.zram = zram;
802803
work.entry = entry;
803804
work.bio = bio;

fs/proc/proc_sysctl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,9 +1626,11 @@ static void drop_sysctl_table(struct ctl_table_header *header)
16261626
if (--header->nreg)
16271627
return;
16281628

1629-
if (parent)
1629+
if (parent) {
16301630
put_links(header);
1631-
start_unregistering(header);
1631+
start_unregistering(header);
1632+
}
1633+
16321634
if (!--header->count)
16331635
kfree_rcu(header, rcu);
16341636

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,7 @@ config TEST_KMOD
19291929
depends on m
19301930
depends on BLOCK && (64BIT || LBDAF) # for XFS, BTRFS
19311931
depends on NETDEVICES && NET_CORE && INET # for TUN
1932+
depends on BLOCK
19321933
select TEST_LKM
19331934
select XFS_FS
19341935
select TUN

lib/test_vmalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ static void shuffle_array(int *arr, int n)
383383
static int test_func(void *private)
384384
{
385385
struct test_driver *t = private;
386-
cpumask_t newmask = CPU_MASK_NONE;
387386
int random_array[ARRAY_SIZE(test_case_array)];
388387
int index, i, j, ret;
389388
ktime_t kt;
390389
u64 delta;
391390

392-
cpumask_set_cpu(t->cpu, &newmask);
393-
set_cpus_allowed_ptr(current, &newmask);
391+
ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
392+
if (ret < 0)
393+
pr_err("Failed to set affinity to %d CPU\n", t->cpu);
394394

395395
for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
396396
random_array[i] = i;

mm/memory_hotplug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
874874
*/
875875
mem = find_memory_block(__pfn_to_section(pfn));
876876
nid = mem->nid;
877+
put_device(&mem->dev);
877878

878879
/* associate pfn range with the zone */
879880
zone = move_pfn_range(online_type, nid, pfn, nr_pages);

mm/page_alloc.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,20 @@ compound_page_dtor * const compound_page_dtors[] = {
266266

267267
int min_free_kbytes = 1024;
268268
int user_min_free_kbytes = -1;
269+
#ifdef CONFIG_DISCONTIGMEM
270+
/*
271+
* DiscontigMem defines memory ranges as separate pg_data_t even if the ranges
272+
* are not on separate NUMA nodes. Functionally this works but with
273+
* watermark_boost_factor, it can reclaim prematurely as the ranges can be
274+
* quite small. By default, do not boost watermarks on discontigmem as in
275+
* many cases very high-order allocations like THP are likely to be
276+
* unsupported and the premature reclaim offsets the advantage of long-term
277+
* fragmentation avoidance.
278+
*/
279+
int watermark_boost_factor __read_mostly;
280+
#else
269281
int watermark_boost_factor __read_mostly = 15000;
282+
#endif
270283
int watermark_scale_factor = 10;
271284

272285
static unsigned long nr_kernel_pages __initdata;
@@ -3419,8 +3432,11 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask)
34193432
alloc_flags |= ALLOC_KSWAPD;
34203433

34213434
#ifdef CONFIG_ZONE_DMA32
3435+
if (!zone)
3436+
return alloc_flags;
3437+
34223438
if (zone_idx(zone) != ZONE_NORMAL)
3423-
goto out;
3439+
return alloc_flags;
34243440

34253441
/*
34263442
* If ZONE_DMA32 exists, assume it is the one after ZONE_NORMAL and
@@ -3429,9 +3445,9 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask)
34293445
*/
34303446
BUILD_BUG_ON(ZONE_NORMAL - ZONE_DMA32 != 1);
34313447
if (nr_online_nodes > 1 && !populated_zone(--zone))
3432-
goto out;
3448+
return alloc_flags;
34333449

3434-
out:
3450+
alloc_flags |= ALLOC_NOFRAGMENT;
34353451
#endif /* CONFIG_ZONE_DMA32 */
34363452
return alloc_flags;
34373453
}
@@ -3773,11 +3789,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
37733789
memalloc_noreclaim_restore(noreclaim_flag);
37743790
psi_memstall_leave(&pflags);
37753791

3776-
if (*compact_result <= COMPACT_INACTIVE) {
3777-
WARN_ON_ONCE(page);
3778-
return NULL;
3779-
}
3780-
37813792
/*
37823793
* At least in one zone compaction wasn't deferred or skipped, so let's
37833794
* count a compaction stall

0 commit comments

Comments
 (0)