lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1105a543-08f8-5284-81a9-3ea6739b489b@virtuozzo.com>
Date:   Mon, 21 May 2018 12:19:12 +0300
From:   Kirill Tkhai <ktkhai@...tuozzo.com>
To:     Vladimir Davydov <vdavydov.dev@...il.com>
Cc:     akpm@...ux-foundation.org, shakeelb@...gle.com,
        viro@...iv.linux.org.uk, hannes@...xchg.org, mhocko@...nel.org,
        tglx@...utronix.de, pombredanne@...b.com, stummala@...eaurora.org,
        gregkh@...uxfoundation.org, sfr@...b.auug.org.au, guro@...com,
        mka@...omium.org, penguin-kernel@...ove.SAKURA.ne.jp,
        chris@...is-wilson.co.uk, longman@...hat.com, minchan@...nel.org,
        ying.huang@...el.com, mgorman@...hsingularity.net, jbacik@...com,
        linux@...ck-us.net, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, willy@...radead.org, lirongqing@...du.com,
        aryabinin@...tuozzo.com
Subject: Re: [PATCH v6 15/17] mm: Generalize shrink_slab() calls in
 shrink_node()

On 20.05.2018 11:08, Vladimir Davydov wrote:
> On Fri, May 18, 2018 at 11:44:11AM +0300, Kirill Tkhai wrote:
>> From: Vladimir Davydov <vdavydov.dev@...il.com>
>>
>> The patch makes shrink_slab() be called for root_mem_cgroup
>> in the same way as it's called for the rest of cgroups.
>> This simplifies the logic and improves the readability.
>>
>> Signed-off-by: Vladimir Davydov <vdavydov.dev@...il.com>
>> ktkhai: Description written.
>> Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
>> ---
>>  mm/vmscan.c |   13 +++----------
>>  1 file changed, 3 insertions(+), 10 deletions(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 2fbf3b476601..f1d23e2df988 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
> 
> You forgot to patch the comment to shrink_slab(). Please take a closer
> look at the diff I sent you:
> 
> @@ -486,10 +486,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
>   * @nid is passed along to shrinkers with SHRINKER_NUMA_AWARE set,
>   * unaware shrinkers will receive a node id of 0 instead.
>   *
> - * @memcg specifies the memory cgroup to target. If it is not NULL,
> - * only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan
> - * objects from the memory cgroup specified. Otherwise, only unaware
> - * shrinkers are called.
> + * @memcg specifies the memory cgroup to target. Unaware shrinkers
> + * are called only if it is the root cgroup.
>   *
>   * @priority is sc->priority, we take the number of objects and >> by priority
>   * in order to get the scan target.
> 
>> @@ -661,9 +661,6 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>>  			.memcg = memcg,
>>  		};
> 
> If you made !MEMCG version of mem_cgroup_is_root return true, as I
> suggested in reply to patch 13, you could also simplify the memcg
> related check in the beginning of shrink_slab() as in case of
> CONFIG_MEMCG 'memcg' is now guaranteed to be != NULL in this function
> while in case if !CONFIG_MEMCG mem_cgroup_is_root() would always
> return true:
> 
> @@ -501,7 +501,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>  	struct shrinker *shrinker;
>  	unsigned long freed = 0;
>  
> -	if (memcg && !mem_cgroup_is_root(memcg))
> +	if (!mem_cgroup_is_root(memcg))

Yeah, we can do this. root_mem_cgroup is also initialized in case of memory
controller is disabled via boot parameters, so this works in all situations.

>  		return shrink_slab_memcg(gfp_mask, nid, memcg, priority);
>  
>  	if (!down_read_trylock(&shrinker_rwsem))
> 
>>  
>> -		if (!!memcg != !!(shrinker->flags & SHRINKER_MEMCG_AWARE))
>> -			continue;
>> -
>>  		if (!(shrinker->flags & SHRINKER_NUMA_AWARE))
>>  			sc.nid = 0;
>>  
>> @@ -693,6 +690,7 @@ void drop_slab_node(int nid)
>>  		struct mem_cgroup *memcg = NULL;
>>  
>>  		freed = 0;
>> +		memcg = mem_cgroup_iter(NULL, NULL, NULL);
>>  		do {
>>  			freed += shrink_slab(GFP_KERNEL, nid, memcg, 0);
>>  		} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
>> @@ -2712,9 +2710,8 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>>  			shrink_node_memcg(pgdat, memcg, sc, &lru_pages);
>>  			node_lru_pages += lru_pages;
>>  
>> -			if (memcg)
>> -				shrink_slab(sc->gfp_mask, pgdat->node_id,
>> -					    memcg, sc->priority);
>> +			shrink_slab(sc->gfp_mask, pgdat->node_id,
>> +				    memcg, sc->priority);
>>  
>>  			/* Record the group's reclaim efficiency */
>>  			vmpressure(sc->gfp_mask, memcg, false,
>> @@ -2738,10 +2735,6 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>>  			}
>>  		} while ((memcg = mem_cgroup_iter(root, memcg, &reclaim)));
>>  
>> -		if (global_reclaim(sc))
>> -			shrink_slab(sc->gfp_mask, pgdat->node_id, NULL,
>> -				    sc->priority);
>> -
>>  		if (reclaim_state) {
>>  			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
>>  			reclaim_state->reclaimed_slab = 0;
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ