Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp560972pxb; Wed, 3 Feb 2021 11:41:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJypw4ebUH+iQJNOuPPkqz0W6NWbhudRolaJt6hIreJ0zCX0EcWhE5AGa89UMYkLWgqQi1+7 X-Received: by 2002:aa7:da17:: with SMTP id r23mr4631081eds.176.1612381296129; Wed, 03 Feb 2021 11:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612381296; cv=none; d=google.com; s=arc-20160816; b=ptqK1stsTC9TgjcEaQo27tMlUCsZ88YkACa1s+JBKWyVeMcuQ214XCHhwowOWC+ExP 3hHo9sHa76+41An+JSCgYIPAy4S5oMhO+O/SeFmcH/F4rH8679nxf44VwkSLYQRlyRWC IjVwJLf8ktJVVKZg2V2MhcEfRDv599KjfhMsT5JsJndyIR189yH0mMFsqT5Rdnu7By+q IfBiUUpnHIOI5irVHj2S2euAqfPkYARr/3327iy5UXcZibrOWzq8HPDuAdz6pzBrr00m /9HRdeQ7Xue6vKVY4/sPt4v/nkzLFcQf94FYL4D+BnA9iInzIe4GHttQyZfqJbyNjH8r Sm9A== 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=qqJHwSkSmfKIXi2zUEG3jTdMT4bjE5ta7BWmjvY+MCI=; b=SNtMmXiZ09eovNvLhcd/8Ahj6z8lADtsSMBEEukrCT7WiqQ2EVv1KGHvfEln94rFK5 9YZTTfEP8Teg4i5Y9RpGfk9T7u4rG+Fz91fsCV95diAO8SmUBA2lP6n/Ttm4+Bqta7Xb dQENS0nhI2+FwBeuFHcU7QTVVxGM23CE+3OS5kl3Mm4NM7IujnhcdZkcS3p1oVzLMq9C APKl/BFx0L1f1cu56SFHYuM30ADGwpriz+UFZdJxk0T1qZJYDZ5MqpEnOP1QLdrRxAKb NRwuR2C+YQyjayl1Q/xuHaD4E6Jm+jv5YL/IIzleh8LNqVbLaFWhrWKZXjx9ZeRlv4js xp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qBpog6Lq; 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 y1si2083554edp.72.2021.02.03.11.41.11; Wed, 03 Feb 2021 11:41:36 -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=qBpog6Lq; 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 S231319AbhBCTiZ (ORCPT + 99 others); Wed, 3 Feb 2021 14:38:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:43484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbhBCTiS (ORCPT ); Wed, 3 Feb 2021 14:38:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 97B5964F5C; Wed, 3 Feb 2021 19:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612381057; bh=trIJo8dzou1rp7IFr9xf7FlYoJLr+1nr80qtsffTyxo=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=qBpog6LqD6UNyZ2mBplShrf724rrUJgnXanvs+B2iEC8QK7ulU2tgQhbAfN2Z67cc Ocqw+Z2lNIExtmJ9jGC253Xcy2jKHQei4orlRS2ZcdsRfTR+stXR77wdgr1IVhDcU8 fIIFoK6ioopqstmJEAKRV3cguyA/NPQkf+zVSHXw0lyGGhdhbDCn6QmVxns7Sso1wN OUkpKVSt70/VltwxfmfONj91TArEEFnpMtteGV37G2H78hgpyoG4Mwm59g7D4ijIKQ 4dXlFGGTu4w5iPuCWv8GiHXcwFGfrgCj/LQ0Kue0nIa5laz/frUhR8ezEC6wPv/ePV 9ZWvm02eAPOSQ== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 36ABE35226F1; Wed, 3 Feb 2021 11:37:37 -0800 (PST) Date: Wed, 3 Feb 2021 11:37:37 -0800 From: "Paul E. McKenney" To: Michal Hocko Cc: Uladzislau Rezki , LKML , RCU , Michael Ellerman , Andrew Morton , Daniel Axtens , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Peter Zijlstra , Thomas Gleixner , "Theodore Y . Ts'o" , Sebastian Andrzej Siewior , Oleksiy Avramchenko Subject: Re: [PATCH 1/3] kvfree_rcu: Allocate a page for a single argument Message-ID: <20210203193737.GK2743@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20210125143150.GA2282@pc638.lan> <20210125153943.GN827@dhcp22.suse.cz> <20210125162559.GA52712@pc638.lan> <20210128151152.GA1867@pc638.lan> <20210128153017.GA2006@pc638.lan> <20210128180237.GA5144@pc638.lan> <20210129163531.GA30500@pc638.lan> 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 Mon, Feb 01, 2021 at 12:47:55PM +0100, Michal Hocko wrote: > On Fri 29-01-21 17:35:31, Uladzislau Rezki wrote: > > On Fri, Jan 29, 2021 at 09:56:29AM +0100, Michal Hocko wrote: > > > On Thu 28-01-21 19:02:37, Uladzislau Rezki wrote: > > > [...] > > > > >From 0bdb8ca1ae62088790e0a452c4acec3821e06989 Mon Sep 17 00:00:00 2001 > > > > From: "Uladzislau Rezki (Sony)" > > > > Date: Wed, 20 Jan 2021 17:21:46 +0100 > > > > Subject: [PATCH v2 1/1] kvfree_rcu: Directly allocate page for single-argument > > > > case > > > > > > > > Single-argument kvfree_rcu() must be invoked from sleepable contexts, > > > > so we can directly allocate pages. Furthermmore, the fallback in case > > > > of page-allocation failure is the high-latency synchronize_rcu(), so it > > > > makes sense to do these page allocations from the fastpath, and even to > > > > permit limited sleeping within the allocator. > > > > > > > > This commit therefore allocates if needed on the fastpath using > > > > GFP_KERNEL|__GFP_NORETRY. > > > > > > Yes, __GFP_NORETRY as a lightweight allocation mode should be fine. It > > > is more robust than __GFP_NOWAIT on memory usage spikes. The caller is > > > prepared to handle the failure which is likely much less disruptive than > > > OOM or potentially heavy reclaim __GFP_RETRY_MAYFAIL. > > > > > > I cannot give you ack as I am not familiar with the code but this makes > > > sense to me. > > > > > No problem, i can separate it. We can have a patch on top of what we have so > > far. The patch only modifies the gfp_mask passed to __get_free_pages(): > > > > >From ec2feaa9b7f55f73b3b17e9ac372151c1aab5ae0 Mon Sep 17 00:00:00 2001 > > From: "Uladzislau Rezki (Sony)" > > Date: Fri, 29 Jan 2021 17:16:03 +0100 > > Subject: [PATCH 1/1] kvfree_rcu: replace __GFP_RETRY_MAYFAIL by __GFP_NORETRY > > > > __GFP_RETRY_MAYFAIL is a bit heavy from reclaim process of view, > > therefore a time consuming. That is not optional and there is > > no need in doing it so hard, because we have a fallback path. > > > > __GFP_NORETRY in its turn can perform some light-weight reclaim > > and it rather fails under high memory pressure or low memory > > condition. > > > > In general there are four simple criterias we we would like to > > achieve: > > a) minimize a fallback hitting; > > b) avoid of OOM invoking; > > c) do a light-wait page request; > > d) avoid of dipping into the emergency reserves. > > > > Signed-off-by: Uladzislau Rezki (Sony) > > Looks good to me. Feel free to add > Acked-by: Michal Hocko Queued, thank you both! Thanx, Paul > > --- > > kernel/rcu/tree.c | 14 +++++++++++++- > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 70ddc339e0b7..1e862120db9e 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -3489,8 +3489,20 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp, > > bnode = get_cached_bnode(*krcp); > > if (!bnode && can_alloc) { > > krc_this_cpu_unlock(*krcp, *flags); > > + > > + // __GFP_NORETRY - allows a light-weight direct reclaim > > + // what is OK from minimizing of fallback hitting point of > > + // view. Apart of that it forbids any OOM invoking what is > > + // also beneficial since we are about to release memory soon. > > + // > > + // __GFP_NOMEMALLOC - prevents from consuming of all the > > + // memory reserves. Please note we have a fallback path. > > + // > > + // __GFP_NOWARN - it is supposed that an allocation can > > + // be failed under low memory or high memory pressure > > + // scenarios. > > bnode = (struct kvfree_rcu_bulk_data *) > > - __get_free_page(GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOMEMALLOC | __GFP_NOWARN); > > + __get_free_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); > > *krcp = krc_this_cpu_lock(flags); > > } > > > > -- > > 2.20.1 > > > > -- > > Vlad Rezki > > -- > Michal Hocko > SUSE Labs