Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp694093pxb; Tue, 3 Nov 2020 09:57:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrabXxVXgTABDYyBI8hWyKPEseicF1Mm/cR01PNw4922uAcUn+SnebOqxCk+acHFITNrie X-Received: by 2002:a17:906:5402:: with SMTP id q2mr20748301ejo.316.1604426265102; Tue, 03 Nov 2020 09:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604426265; cv=none; d=google.com; s=arc-20160816; b=ikjqWYas1z9KqRwgqfEQ0I3aVfLGz3UKU5RyJCI6IOKHFfX/A+XPJ9h6ShHTdtouPQ M2yJgcu7neP0wTR1aYGcKF5AgUzVBEdTo/e/3lee7A/C3QqLLBWIHEBbA98Cj6IdDmDK wRGPmLh1k2RGoxqOI0LDN8zPGTXAQC5JQqwcckDjSemiIhYTTo6RFYbTR9SW1zqTc7GZ WHWvGsmxcp4XAntAw0911wAXbqIvKf+7VY5MPTtW5Om6+q5MLFFdg/AxJpuYZFhT8u/9 S17ZM6j6oVF6xyzQdtQivZl/kDrsVq+6heB9Dldr6C1xhfaSLZ6gqS/nVHwdAtDpjfLF jyhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gQIdH+KYMzHor18vx9OZ/2FWWOokJq94zc6XYSXneW0=; b=ckwJiQOvvzrAk8QdcMt3DoFUBx4RhNNJl1psW8ZLkaQkWmLd3fpqJj0AP1UFpXELbh hIhRjihPbeYg8ZtAqBUHL4am9ZPc1WWN5PzLJD9EUi2XwESR3O9q4tkWjPW3ZyCXZtLq pIzHBQubiP3EtoSNJd9CRFRZIWbMHZDNuowGNXHDR3QnhJL0IlUgZx3xGLF8hhzqhhMA 8WYidbzKYDMSAKlCVL+laXUROwPF2jlMyKbjL5ygzEtAww0Qceet3aIBhE8FZ5btGzQH UbCMpNw4Jqjbv/HSiHXL+KUURjcPDL1m9gxrmTHVHTHE3DYMxMTepJsaDwdlokgfZspW ayBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=DpKEK4aB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si13686429edn.152.2020.11.03.09.57.22; Tue, 03 Nov 2020 09:57:45 -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=@joelfernandes.org header.s=google header.b=DpKEK4aB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729020AbgKCRyY (ORCPT + 99 others); Tue, 3 Nov 2020 12:54:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbgKCRyY (ORCPT ); Tue, 3 Nov 2020 12:54:24 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F410BC0613D1 for ; Tue, 3 Nov 2020 09:54:23 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id i21so14839777qka.12 for ; Tue, 03 Nov 2020 09:54:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gQIdH+KYMzHor18vx9OZ/2FWWOokJq94zc6XYSXneW0=; b=DpKEK4aB/HIU11tArZycrVOChpZNTGD38KrzZpwB5kFti7K3eOMs9D9aPUFn3Uj44c qrLBR2lDtk/ORa1oOhdnrMbCizV2xKCvjfgEQu7Afd125n+/ABz0aMIoL90AZajKPQO/ i3fK5Ob1fcokwezA1t0bDBBh0510gobzD0bag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gQIdH+KYMzHor18vx9OZ/2FWWOokJq94zc6XYSXneW0=; b=nHNfrayOKElkTaU4pnZniW+s4FczRE8iDFtGUtc4vn67BMYCjAFAR3BbBvUV9PyoI9 LarEQ+sM496LO+s5c8oqoPvM/KzVpigpQoO/kH+acSc4zS5VFXTBaTt02i9OXexsnoYc 7D1/0s19Cihxi16vItS7jYG4uYwoOP96ilhUKNcUyPVA4NYz6uzeMMUjAsGp/12K8/j9 FJPS3stX3oBtZ7CkBdZqJUnz+5X7LgWkQSoJj4tHbNpDtPE+4kVUZTutYOjw46jKBOuS /SdoPRUtEgmxOG3aMMl4CqRWv2Tm/KGD+x3ojqxpOECAp+jaqbaX9+9W3LVDVm9vaO5U Vm9g== X-Gm-Message-State: AOAM530prgKLpIDOXqiFf3OO+lx0fFoNIT4w1wKL62og7aXIKmJqf2Jf mFP8XI7wzw9A3f4r+9KvCQR6Ig== X-Received: by 2002:a37:315:: with SMTP id 21mr21262307qkd.330.1604426063190; Tue, 03 Nov 2020 09:54:23 -0800 (PST) Received: from localhost ([2620:15c:6:411:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id v206sm4234881qkb.114.2020.11.03.09.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 09:54:22 -0800 (PST) Date: Tue, 3 Nov 2020 12:54:22 -0500 From: Joel Fernandes To: "Uladzislau Rezki (Sony)" Cc: LKML , RCU , "Paul E . McKenney" , Andrew Morton , Peter Zijlstra , Michal Hocko , Thomas Gleixner , "Theodore Y . Ts'o" , Sebastian Andrzej Siewior , Oleksiy Avramchenko Subject: Re: [PATCH 01/16] rcu/tree: Add a work to allocate pages from regular context Message-ID: <20201103175422.GB1310511@google.com> References: <20201029165019.14218-1-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201029165019.14218-1-urezki@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2020 at 05:50:04PM +0100, Uladzislau Rezki (Sony) wrote: > The current memmory-allocation interface presents to following > difficulties that this patch is designed to overcome [...] > --- > kernel/rcu/tree.c | 109 ++++++++++++++++++++++++++++------------------ > 1 file changed, 66 insertions(+), 43 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 06895ef85d69..f2da2a1cc716 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -177,7 +177,7 @@ module_param(rcu_unlock_delay, int, 0444); > * per-CPU. Object size is equal to one page. This value > * can be changed at boot time. > */ > -static int rcu_min_cached_objs = 2; > +static int rcu_min_cached_objs = 5; > module_param(rcu_min_cached_objs, int, 0444); > > /* Retrieve RCU kthreads priority for rcutorture */ > @@ -3084,6 +3084,9 @@ struct kfree_rcu_cpu_work { > * In order to save some per-cpu space the list is singular. > * Even though it is lockless an access has to be protected by the > * per-cpu lock. > + * @page_cache_work: A work to refill the cache when it is empty > + * @work_in_progress: Indicates that page_cache_work is running > + * @hrtimer: A hrtimer for scheduling a page_cache_work > * @nr_bkv_objs: number of allocated objects at @bkvcache. > * > * This is a per-CPU structure. The reason that it is not included in > @@ -3100,6 +3103,11 @@ struct kfree_rcu_cpu { > bool monitor_todo; > bool initialized; > int count; > + > + struct work_struct page_cache_work; > + atomic_t work_in_progress; Does it need to be atomic? run_page_cache_work() is only called under a lock. You can use xchg() there. And when you do the atomic_set, you can use WRITE_ONCE as it is a data-race. > @@ -4449,24 +4482,14 @@ static void __init kfree_rcu_batch_init(void) > > for_each_possible_cpu(cpu) { > struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu); > - struct kvfree_rcu_bulk_data *bnode; > > for (i = 0; i < KFREE_N_BATCHES; i++) { > INIT_RCU_WORK(&krcp->krw_arr[i].rcu_work, kfree_rcu_work); > krcp->krw_arr[i].krcp = krcp; > } > > - for (i = 0; i < rcu_min_cached_objs; i++) { > - bnode = (struct kvfree_rcu_bulk_data *) > - __get_free_page(GFP_NOWAIT | __GFP_NOWARN); > - > - if (bnode) > - put_cached_bnode(krcp, bnode); > - else > - pr_err("Failed to preallocate for %d CPU!\n", cpu); > - } > - > INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor); > + INIT_WORK(&krcp->page_cache_work, fill_page_cache_func); > krcp->initialized = true; During initialization, is it not better to still pre-allocate? That way you don't have to wait to get into a situation where you need to initially allocate. AFAICS after the above line deletions, the bulk pages are initially empty. thanks, - Joel > } > if (register_shrinker(&kfree_rcu_shrinker)) > -- > 2.20.1 >