Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp553322ybb; Wed, 1 Apr 2020 05:26:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsTwsqjFXWW7yyWICoacIArTLG0kFBFFQEhvhIgdwXZpwZbYWyLDaSUQ63r5NbJxe+oP9qs X-Received: by 2002:a9d:128:: with SMTP id 37mr16202262otu.270.1585744000836; Wed, 01 Apr 2020 05:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585744000; cv=none; d=google.com; s=arc-20160816; b=kqT3mUzfs/sBIsK8fah2X0w0pNAFQ3IgoDPGBEXdIq4DwvzFxPw5j9FnEU7Gjcp3n6 I+ETU3EHOYELh6w5+0zePaICUZjLVZnF8qs9zQ83LuIDC8euA51in2gTgNVndQAt8cVj kfXQQQwlTaNfMzUbvPxdLJ4+Mfo21Dmdn3OCFf+PCPcb0ohWg6OleYwX9qwP5lrqsQBc r3MTz7CUPzGV11qKA0cEMuFZ4EvK+0xXM91TUGZ8nk55ZdGTNZi8ZUoyPt39entRY/GT HB55Al/L3pUwpMQoMRIBr1gM3aszATtt/qin33A7p1UUn8XYYBTZ05XtueCFA+xg0GEX laxA== 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:message-id:subject:cc :to:date:from:dkim-signature; bh=piX7MZ/AAi4ncX0sPDXAqjMsG1O4fj7Yh16uYtERXCY=; b=vuaXouT5UQ8y+KmqvfoCG0Nre2Bs0fRMO5x3EEcBRUDoHNHIixCXRdgtk2vhcBEN5P Ehvo7hVJu8fy4caJLFZj855beIs8zeH3HOnuP8IbruS169BECGpzV28sl+8slaxxTpnG YQty2A2JgEIOGTn1Z1xjgwGsLgFFv4WxmCqT2cNlcxziZt/FSLOYfzqJVHn3P4cWg6tJ u9+WZh8tx+T9noCSG0ALFdRZRU9FhrGEgpZWfOP7s6e4zpgagPiKS51Vu9rJQS5qW+5x GH3e2WK1c/2OC54UO/5q2mcap5mBWDlnSANdTd2xOEagtNG2Ep8k9SufhbOHHmsy10Na WV5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ctg3aX71; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si348022otk.29.2020.04.01.05.26.27; Wed, 01 Apr 2020 05:26:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ctg3aX71; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732435AbgDAM0B (ORCPT + 99 others); Wed, 1 Apr 2020 08:26:01 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35409 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732253AbgDAM0B (ORCPT ); Wed, 1 Apr 2020 08:26:01 -0400 Received: by mail-lj1-f194.google.com with SMTP id k21so25563174ljh.2; Wed, 01 Apr 2020 05:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=piX7MZ/AAi4ncX0sPDXAqjMsG1O4fj7Yh16uYtERXCY=; b=ctg3aX71wlaxZ+E0dbXZnFhoIYpLbM8wvmUkUKAwEsSgCskn6batI4na7JrJUCGa1f 11fyES5yxs+XTvJHSgIbe6TgJApeBhmBgklGt8io20lKwgK+d1ktngJn93dHO3dJFtM9 2YIsDVhV2irv0eNTrPAcHs42mDuCEibhyOcTJWqqcyaY9dOBgkzv4au3IBt1gJnwEW6M Yi3IBT9Oqs1unEhmlklzl0tjt5aYgKVkDmGrtJRtcFeluSafhg0VHY5VElbYd/R2WqgI aVAp3ysYIGRd0tNAcWnv5EVHD3ysKWpD9xhrJ5k9QYf9mw/dy9NB3vpFJ1F2Hs6xBmGT DV+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=piX7MZ/AAi4ncX0sPDXAqjMsG1O4fj7Yh16uYtERXCY=; b=E4DCsJoWFwNqnQnQJhthOs2JqTo0KT9KZD/3GTDJL60G0LnIVCJl+hp/tVWqkDEEMn KoQbzBuRjAmsvRn+AKjlPPU71seDmCcVGPMlQNX9wLTtO90ml27TW9zc0QiBzlCrD/bk U5i2GLyAeRLm+ju6EQJnplVbp2C1tKlSx/7VGBAJm4A8dGsvkw98o4QV7MGpPMupVHOM B3GyQrpAcTBxEnPHbj/EKBc8HG+kN3g4Xaj4n9+OOEfaMxinc6l82kua6aiIAbd2e6tE UrYZ51no112qYhG8Wc5g1fZoz70dvqmJvExZTR1Q8UimwbxwCtj1KWWXlMlMmmQfml4Y YVSQ== X-Gm-Message-State: AGi0PuZqIfFHeJ+/fppjVyJpQLkbrUcdzKGJtJ/w5R4Nc9m2RXLHB1UL e3K3xQo/SGwQl+MxEwuF3+s= X-Received: by 2002:a2e:a40b:: with SMTP id p11mr6488526ljn.173.1585743958538; Wed, 01 Apr 2020 05:25:58 -0700 (PDT) Received: from pc636 (h5ef52e31.seluork.dyn.perspektivbredband.net. [94.245.46.49]) by smtp.gmail.com with ESMTPSA id k3sm1149610lji.43.2020.04.01.05.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 05:25:57 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Wed, 1 Apr 2020 14:25:50 +0200 To: Joel Fernandes Cc: Uladzislau Rezki , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org, willy@infradead.org, peterz@infradead.org, neilb@suse.com, vbabka@suse.cz, mgorman@suse.de, Andrew Morton , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , Steven Rostedt Subject: Re: [PATCH RFC] rcu/tree: Use GFP_MEMALLOC for alloc memory to free memory pattern Message-ID: <20200401122550.GA32593@pc636> References: <20200331131628.153118-1-joel@joelfernandes.org> <20200331140433.GA26498@pc636> <20200331150911.GC236678@google.com> <20200331160119.GA27614@pc636> <20200331183000.GD236678@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331183000.GD236678@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > I think there should be GFP_ATOMIC used, because it has more chance to > > return memory then GFP_NOWAIT. I see that Michal has same view on it. > > I don't think so because GFP_ATOMIC implies GFP_NOWAIT. I am Ok with keeping > the GFP_ATOMIC as it is btw. Paul mentioned he prefers this. I agree with > that as well. > GFP_ATOMIC can access to reserved memory whereas GFP_NOWAIT is not eligible to do so. So there is difference between them :) > > > > > > Yes, the benefit of the trace/warning is that the user can switch to a > > > non-headless API and avoid the synchronize_rcu(), that would help them get > > > faster kfree_rcu() performance instead of having silent slowdowns. > > > > > Agree. What about just adding WARN_ON_ONCE()? I am just thinking if it > > could be harmful or not. > > You mean WARN_ON_ONCE() before the synchronize_rcu() right? We could do that. > Paul mentioned to me he prefers if this new warning can be turned off with a > boot parameter since some future user may prefer no warning. I also agree. > Yes, we can add it before doing synchronize_rcu(). WARN_ON_ONCE() will emit only once the warning. I think that would be enough to pay an attention. > > If we add this then we can keep your __GFP_NOWARN flag with no additional GFP > flag changes. > We can also add __GFP_RETRY_MAYFAIL to GFP_ATOMIC to make it more tight. Basically your patch can be modified just adding that. > > > It also tells us whether the headless API is worth it in the long run, I > > > think it is worth it because we will likely never hit the synchronize_rcu() > > > failsafe. But if we hit it a lot, at least it wont happen silently. > > > > > Agree. > > > > > Paul was concerned about following scenario with hitting synchronize_rcu(): > > > 1. Consider a system under memory pressure. > > > 2. Consider some other subsystem X depending on another system Y which uses > > > kfree_rcu(). If Y doesn't complete the operation in time, X accumulates > > > more memory. > > > 3. Since kfree_rcu() on Y hits synchronize_rcu() a lot, it slows it down. > > > This causes X to further allocate memory, further causing a chain > > > reaction. > > > Paul, please correct me if I'm wrong. > > > > > I see your point and agree that in theory it can happen. So, we should > > make it more tight when it comes to rcu_head attachment logic. > > Right. Per discussion with Paul, we discussed that it is better if we > pre-allocate N number of array blocks per-CPU and use it for the cache. > Default for N being 1 and tunable with a boot parameter. I agree with this. > As discussed before, we can make use of memory pool API for such purpose. But i am not sure if it should be one pool per CPU or one pool per NR_CPUS, that would contain NR_CPUS * N pre-allocated blocks. > In current code, we have 1 cache page per CPU, but this is allocated only on > the first kvfree_rcu() request. So we could change this behavior as well to > make it pre-allocated. > > Does this all sound good to you? > I think that makes sense :) -- Vlad Rezki