Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1808863pxb; Mon, 8 Mar 2021 06:58:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzInZYKLDBl71phXSxt248Os7i3DMY9vWqSzhren2FG6yotaGIJuVbgCiMPTxEn5Ak++1Yh X-Received: by 2002:a17:906:2404:: with SMTP id z4mr15115134eja.14.1615215520568; Mon, 08 Mar 2021 06:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615215520; cv=none; d=google.com; s=arc-20160816; b=RqgPy4eXKdHhH2s4sX82klEZyWmgWbpNLlVuH0zD44M/Zqb+pMbR50JYG8UiM52fT9 Kc1CWzZpd6oyQnIKKFFU6W3ZeLin/y8mWra5al7snh3tzT8l0XMXP0Sk7mgyMPTdgYgJ ufHOn9NwJpxEl1zZ8cjf4Vu0OgI583u2TJmEn57SU5Gt6uAeWNvYGAszcYkOk29azkil f4+ds/DWMgXBokoN2b+jAoIsVbK5cATmI1hNsVcW7M1hXw22A+Rhu2MyEQl+55Mym79O X7ijegKxt7nsKk+4Y6ltocbo1Oy3WgbcdeAXkV2YKwGv2/BvYShh3Po0mn1gG1GpBTp8 RL/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=aaNa2LOVnaMpPh2C2j2dmzBYP0CFQSVdK3R5EXZd/AA=; b=Vt9RLAZbadF/8Qtl2wQruiP0yB6midiWa23XP78y3s4wKVY7pWVldsYetkaBggDrNT 6pb3H9xnDTqSINnQqY8Y1yO9gHFC31wrr0jmHc0aNzXRB15AJJ7YLmzbsJUgPrYsN78u S7utalPRe8ZyMQMdthw6FQTItmMb1ZmZKWAcxZgWdZVgbl3aZGZhv71KH5J4JT62byTA BoZaR4MasBpTJFAzPsZ42RjOtkCAMg92CpmpcQl2xWN6InbhM50dyzyLF39yj5KZhzcq rJMfcpQmqb49jeXM4e04uASskcGWsY6kjSjwFpdfOr9gAQSXn92wC4UMW1sQR2HLA7mL KlRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="spN/4KqC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz2si6866517ejb.140.2021.03.08.06.58.16; Mon, 08 Mar 2021 06:58:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="spN/4KqC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhCHOzG (ORCPT + 99 others); Mon, 8 Mar 2021 09:55:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:48514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbhCHOyp (ORCPT ); Mon, 8 Mar 2021 09:54:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D45BA650E6; Mon, 8 Mar 2021 14:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615215284; bh=X0lo3Qat103XhQ7n/pn8ZYoJZykAVsMGsMiUCcu70Gg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=spN/4KqC5tfWitVZ0K4hQKMgdT5PR7dE0yZ4vY3o/eTBu+ZJKHDmjX0GRAjR56shy sIBrrKwmWso/Ujqm3NAFRWP+nMmivkGG+eTEaF+1qPy62alkQ281yTtyuaE2EZauCs tWtbEHqaDqapcSrOg0sJ9PshTRbx7bGKEiAV1bwTvO/w0mPFLyZ00S6o6Gqg78SUBL URzO0Fblz7kem2JXTK+9UHraUjl+yXtrT3PxudL2JE9SMAP01qJ9UmTc97H6LNhdD/ 4yFZkn2E6Q4SttLFGWFWtbonCNKjX2Pp1YIXufEG0eOy3EObsGcLTgKM2IEGPq3yq2 YeYAJirKmLHMg== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 9C23B35239E1; Mon, 8 Mar 2021 06:54:44 -0800 (PST) Date: Mon, 8 Mar 2021 06:54:44 -0800 From: "Paul E. McKenney" To: Shakeel Butt Cc: Yang Shi , Roman Gushchin , Kirill Tkhai , Vlastimil Babka , Dave Chinner , Johannes Weiner , Michal Hocko , Andrew Morton , Linux MM , linux-fsdevel , LKML Subject: Re: [v8 PATCH 05/13] mm: vmscan: use kvfree_rcu instead of call_rcu Message-ID: <20210308145444.GN2696@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20210217001322.2226796-1-shy828301@gmail.com> <20210217001322.2226796-6-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 07, 2021 at 10:13:04PM -0800, Shakeel Butt wrote: > On Tue, Feb 16, 2021 at 4:13 PM Yang Shi wrote: > > > > Using kvfree_rcu() to free the old shrinker_maps instead of call_rcu(). > > We don't have to define a dedicated callback for call_rcu() anymore. > > > > Signed-off-by: Yang Shi > > --- > > mm/vmscan.c | 7 +------ > > 1 file changed, 1 insertion(+), 6 deletions(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 2e753c2516fa..c2a309acd86b 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -192,11 +192,6 @@ static inline int shrinker_map_size(int nr_items) > > return (DIV_ROUND_UP(nr_items, BITS_PER_LONG) * sizeof(unsigned long)); > > } > > > > -static void free_shrinker_map_rcu(struct rcu_head *head) > > -{ > > - kvfree(container_of(head, struct memcg_shrinker_map, rcu)); > > -} > > - > > static int expand_one_shrinker_map(struct mem_cgroup *memcg, > > int size, int old_size) > > { > > @@ -219,7 +214,7 @@ static int expand_one_shrinker_map(struct mem_cgroup *memcg, > > memset((void *)new->map + old_size, 0, size - old_size); > > > > rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_map, new); > > - call_rcu(&old->rcu, free_shrinker_map_rcu); > > + kvfree_rcu(old); > > Please use kvfree_rcu(old, rcu) instead of kvfree_rcu(old). The single > param can call synchronize_rcu(). Especially given that you already have the ->rcu field that the two-argument form requires. The reason for using the single-argument form is when you have lots of little data structures, such that getting rid of that rcu_head structure is valuable enough to be worth the occasional call to synchronize_rcu(). However, please note that this call to synchronize_rcu() happens only under OOM conditions. Thanx, Paul