Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp590396pxk; Thu, 1 Oct 2020 09:31:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4kaf8hgDkSKZuhU3jULDMYbtkLPhMXDiyt5lTXuEkDuTILHVDd8RWG8eaoc0oPjkg7L2b X-Received: by 2002:a05:6402:17fc:: with SMTP id t28mr9163838edy.244.1601569886940; Thu, 01 Oct 2020 09:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601569886; cv=none; d=google.com; s=arc-20160816; b=jgHKz9hUfOIUBMSh9/NCdfS+1q4ox7FiG4W/+x2g2oYhM3aemCbPfP3xP6lWYClsif J47CT4LSCfEqz9fDF8VmZZ0PF4b7FfIp5Jk1YR0W7dIEholveIqWF0z6CgxcOpO5B3jQ Uk5zXyAAkT2WlH/e4+I9++s2wpCTG813DvmcEdO2+hOH/OGAH0jkjyGRjV3jqYp/x/ag eHAachk0LzbreICT1xpaDQ6e9IWE54FNAaQiP7MTRgVLUaPNm7TLKBjxJqkdG6QDpEwK BiVmekBZ+p/HqPKVeuMM4AoC/8AEQpUhORySk7S72D8fbmvu6H1IqTMkomgXVxhIsKLg KngQ== 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=Ialsw70MY2HnOykzuuwOZfMsA0IwsnyXdFXphyTmfwE=; b=szYsTrIkFf+XMWeFu4DCZfQCDpr8ndZ0EJJShnDRZg7kB7/XAJmgzQ19Z/1XV1Hd1g ko4rDeyl2NGx7vneQ17rh4FEzEzWXXyEKSSQIVLgKvoMJGRZKO1S2hJDC75ppPgFq1Br Wnmhyq8y2az/kWTFMPu4YfyiwuG72hrk8hFMA1rAczMyQEn4mXZ+sj1yWcQaj0/aESoT 3gEFOC3KZ6NhF/6IqGigFgweTjD8d1rQMAE5GtIRK8uzJioEY3hGwyHt3fUNAH3E/H1d rbszzc6ePs2H1IC7xv+ZDkOmcA1F2/Y3NEgpKMkFgJ3F8C1muis0D3RVBI1BpP7OCQ4b j2Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bFiZqfth; 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 bw19si3868084ejb.208.2020.10.01.09.31.03; Thu, 01 Oct 2020 09:31:26 -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=bFiZqfth; 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 S1732741AbgJAQ2i (ORCPT + 99 others); Thu, 1 Oct 2020 12:28:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:53072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730534AbgJAQ2g (ORCPT ); Thu, 1 Oct 2020 12:28:36 -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 CC16620759; Thu, 1 Oct 2020 16:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601569715; bh=06LQkY9IlXJfgXC7Wh55LnpusDxLGBsMuKUUmE57yVs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=bFiZqfthdzJPwxRJ/8lWpAEhyiI9OHzQre5d0GNAvkSaw3gnif2i6tyB6dRkUJCfu mLk/+M6OpQHO/xqk/+N631yxHroEfDsrEDdwNeIKxIzkIKFAfiQyVdPmrlJdSZt0NC SGc8lNPCxxAgGKriqJkw5z6DzqYnN3prL2Ta1XKU= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 6E92D3522B33; Thu, 1 Oct 2020 09:28:35 -0700 (PDT) Date: Thu, 1 Oct 2020 09:28:35 -0700 From: "Paul E. McKenney" To: Michal Hocko Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, mgorman@techsingularity.net, torvalds@linux-foundation.org, "Uladzislau Rezki (Sony)" Subject: Re: [PATCH tip/core/rcu 14/15] rcu/tree: Allocate a page when caller is preemptible Message-ID: <20201001162835.GE29330@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200928233041.GA23230@paulmck-ThinkPad-P72> <20200928233102.24265-14-paulmck@kernel.org> <20200929120756.GC2277@dhcp22.suse.cz> <20200930015327.GX29330@paulmck-ThinkPad-P72> <20200930084139.GN2277@dhcp22.suse.cz> <20200930232154.GA29330@paulmck-ThinkPad-P72> <20201001090220.GA22560@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201001090220.GA22560@dhcp22.suse.cz> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 01, 2020 at 11:02:20AM +0200, Michal Hocko wrote: > On Wed 30-09-20 16:21:54, Paul E. McKenney wrote: [ . . . ] Hit "send" too soon, apologies... > > ------------------------------------------------------------------------ > > > > commit 490b638d7c241ac06cee168ccf8688bb8b872478 > > Author: Paul E. McKenney > > Date: Wed Sep 30 16:16:39 2020 -0700 > > > > kvfree_rcu(): Switch from kmalloc/kfree to __get_free_page/free_page. > > > > The advantages of using kmalloc() and kfree() are a possible small speedup > > on CONFIG_SLAB=y systems, avoiding the allocation-side cast, and use of > > more-familiar API members. The advantages of using __get_free_page() > > and free_page() are a possible reduction in fragmentation and direct > > access to the buddy allocator. > > > > To help settle the question as to which to use, this commit switches > > from kmalloc() and kfree() to __get_free_page() and free_page(). > > > > Suggested-by: Michal Hocko > > Suggested-by: "Uladzislau Rezki (Sony)" > > Signed-off-by: Paul E. McKenney > > Yes, looks good to me. I am not entirely sure about the fragmentation > argument. It really depends on the SL.B allocator internals. The same > applies for the potential speed up. I would be even surprised if the > SLAB was faster in average considering it has to use the page allocator > as well. So to me the primary motivation would be "use the right tool > for the purpose". Very well, I will update the commit message, and thank you! Thanx, Paul > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 2886e81..242f0f0 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -3225,7 +3225,8 @@ static void kfree_rcu_work(struct work_struct *work) > > bkvhead[i] = NULL; > > krc_this_cpu_unlock(krcp, flags); > > > > - kfree(bkvhead[i]); > > + if (bkvhead[i]) > > + free_page((unsigned long)bkvhead[i]); > > > > cond_resched_tasks_rcu_qs(); > > } > > @@ -3378,7 +3379,7 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp, > > bnode = get_cached_bnode(*krcp); > > if (!bnode && can_alloc_page) { > > krc_this_cpu_unlock(*krcp, *flags); > > - bnode = kmalloc(PAGE_SIZE, gfp); > > + bnode = (struct kvfree_rcu_bulk_data *)__get_free_page(gfp); > > *krcp = krc_this_cpu_lock(flags); > > } > > > > -- > Michal Hocko > SUSE Labs