Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3254750pxa; Tue, 18 Aug 2020 10:19:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSuJs0veovE4B/pJnsWnKdkMQajQzZe8VzKD+X1tYZfhCmUV865QfKoOWOfl9OXdtiVtyO X-Received: by 2002:a17:906:33d1:: with SMTP id w17mr22756978eja.68.1597771160187; Tue, 18 Aug 2020 10:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597771160; cv=none; d=google.com; s=arc-20160816; b=XQJkIQ7rBttGtqUDSdmNy0ypDOLuMZCVTZTeG//ZW/SsNyBAvSQNTU8pGDn/Mhyz/C i9htMujhk9Ivqdyqy8Pmx3hZdEuCw93anl5D6uX42w579iX9mNS0wvH58uB6wbSfzzdI hDg8MKou9KGbrPCJPiy66CHkux74ruDjC5z0txA0r0QXwbTaMAbsqSiTtrEpxHBrynpL PlYgI74YbXeFWLXaS6MPzjbyL3U1N1QcshuZQfGxbcpNRTAYCP+0Iy6A90X0rg1ZqjoJ BBUXivjL/F7soa9C8KsK23WNzd5DY6PO4qhC34hAMVGNvrBkKNh2yKUgGP8eZ24ctFtc 8IIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=kQf1cgwMnTmQMZlJ12lgB3ErUajYfd+Y1Yv88FB8jBw=; b=fL/xlB/u/CPB4Pdk8wWDoNPEfYQExFauwDKmcxp3mlRHA0UY8XDuT5LjqrYknv6S/D onNr5+zwan/eCVmOg42ae9iy+91irLTsazyNzvFHu2EBWctZP2hX1lKY2CFFQzeF5A5B plVZCxqUMX7dABMXgRr2cF09LHPN9pPl0Y4kaU1eXSBBSt1dOkz9HyDv4T0B8NVCYudN Uju5MnkXLfAvRFDEJabsxNiSbJYIazlbwU5vHQhBYBJ6wpnCTRSe073Nge3VNWwD+r3W GWIUWaZk8rLVfhse79ZuH2KAsrrvE6Yr8tVTPGkIE6UrIVLRnmec3twOzxDPZYH+Jd/u kQew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G2uzu5rV; 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 qn22si13859438ejb.586.2020.08.18.10.18.56; Tue, 18 Aug 2020 10:19:20 -0700 (PDT) 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=default header.b=G2uzu5rV; 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 S1728122AbgHRRSL (ORCPT + 99 others); Tue, 18 Aug 2020 13:18:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:54306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgHRRSI (ORCPT ); Tue, 18 Aug 2020 13:18:08 -0400 Received: from paulmck-ThinkPad-P72.home (unknown [50.45.173.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE5DF20658; Tue, 18 Aug 2020 17:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597771087; bh=BHcNycc4dZBlyvyM2oisP4r82JOuw/+7vT2Hq+RP4rg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=G2uzu5rVo9qgnohWdcmBBqslx+OIONWh7jmdSNIxCGhJ4Bay3lsoZcbgQM3OkW4ML 6h6GUghZyHln6EgzKX7X5E3ir5FjBl5F3n78TtDeoWhnxJ5gG5PDMwtCo5y2h5AkcF j5PexCbKO//1QMrK6T71jGVEyED9bPjpCY4aK0ZA= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 8E6B735228F5; Tue, 18 Aug 2020 10:18:07 -0700 (PDT) Date: Tue, 18 Aug 2020 10:18:07 -0700 From: "Paul E. McKenney" To: Joel Fernandes Cc: Uladzislau Rezki , qiang.zhang@windriver.com, Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , rcu , LKML Subject: Re: [PATCH] rcu: shrink each possible cpu krcp Message-ID: <20200818171807.GI27891@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200814064557.17365-1-qiang.zhang@windriver.com> <20200814185124.GA2113@pc636> 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 17, 2020 at 06:03:54PM -0400, Joel Fernandes wrote: > On Fri, Aug 14, 2020 at 2:51 PM Uladzislau Rezki wrote: > > > > > From: Zqiang > > > > > > Due to cpu hotplug. some cpu may be offline after call "kfree_call_rcu" > > > func, if the shrinker is triggered at this time, we should drain each > > > possible cpu "krcp". > > > > > > Signed-off-by: Zqiang > > > --- > > > kernel/rcu/tree.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index 8ce77d9ac716..619ccbb3fe4b 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -3443,7 +3443,7 @@ kfree_rcu_shrink_count(struct shrinker *shrink, struct shrink_control *sc) > > > unsigned long count = 0; > > > > > > /* Snapshot count of all CPUs */ > > > - for_each_online_cpu(cpu) { > > > + for_each_possible_cpu(cpu) { > > > struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu); > > > > > > count += READ_ONCE(krcp->count); > > > @@ -3458,7 +3458,7 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) > > > int cpu, freed = 0; > > > unsigned long flags; > > > > > > - for_each_online_cpu(cpu) { > > > + for_each_possible_cpu(cpu) { > > > int count; > > > struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu); > > > > > > @@ -3491,7 +3491,7 @@ void __init kfree_rcu_scheduler_running(void) > > > int cpu; > > > unsigned long flags; > > > > > > - for_each_online_cpu(cpu) { > > > + for_each_possible_cpu(cpu) { > > > struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu); > > > > > > raw_spin_lock_irqsave(&krcp->lock, flags); > > > > > I agree that it can happen. > > > > Joel, what is your view? > > Yes I also think it is possible. The patch LGTM. Another fix could be > to drain the caches in the CPU offline path and save the memory. But > then it will take hit during __get_free_page(). If CPU > offlining/online is not frequent, then it will save the lost memory. > > I wonder how other per-cpu caches in the kernel work in such scenarios. > > Thoughts? Do I count this as an ack or a review? If not, what precisely would you like the submitter to do differently? Thanx, Paul