Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3729403ybb; Tue, 31 Mar 2020 10:50:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvtis0JV3pwQxpMWXTvicLVOV5QS66j4e/172+szKxHpg69zCojlRzFFsciT3Zy/KNd5Igh X-Received: by 2002:a4a:1882:: with SMTP id 124mr14213985ooo.60.1585677056310; Tue, 31 Mar 2020 10:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585677056; cv=none; d=google.com; s=arc-20160816; b=SVFld0kXMdwMuNTjvknauLPSyv5xUomrxy/RCXB6BIV5pG8aEnIPWAaMDlANkGbbOs vZ9ozqP9zoWORHuyjFqMvALNoKaaZBLcUzLLPt5JqKoSYrs4vJxa9eenPw6nOfRHOvZ/ t2IGKiNUqygVEoKhYF+IkQEBqs4uFQ1htnXPMegJHtexhx+0plZoSViDBcLTLMmzK7Yq zppoZi0JWxvMozs/eXEVC1QKCMKLn/ixRV1/uzX738zaxIp8fcMO8b3QLGrp5k+JKZ2K QRC0ntH9P47hRngJ+Op4br1qCcpSgZKobDjiFx4ny8nz5ZbNtwxaR9X2MRpGv5QIoQih lXzg== 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=xtHm7PG0cNz6MLoLxA4+UMddzcxHL/NJvLi8SdoSZk4=; b=T/f9vAexbCfWpemN8dIlyIa53YDL9aP5DLrlPDi5R5s7qL9hQRcP1or/K6v3gOKP7x 3YDjXR9egIwE23qzAVCDaTfb1H/P1xM7B1DmqIlIgBbop9X/iyVpRrH/gHxZwefL8jYd ge03RZk5coVPyGy56GLEaOlY5RQ9yYc/PEXho4fl+bIEInpIYnt7GZK9L11Z3DoVgx/8 Hq3wcohljoR/UlfaByG2Vi+tekiDR/llQHlP2SUdtj4bpw6IaFNizK1O8B4lJHg0k9Ib JbYSO9Hh0hRRCDEEbH/vWn18uNagXJuF2ZxXC8WUMdWJpanepGy8c5kkMqv+KEFfd8fp ciZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cYgWjwN1; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si6567814otq.313.2020.03.31.10.50.43; Tue, 31 Mar 2020 10:50:56 -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=@kernel.org header.s=default header.b=cYgWjwN1; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbgCaRtG (ORCPT + 99 others); Tue, 31 Mar 2020 13:49:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbgCaRtF (ORCPT ); Tue, 31 Mar 2020 13:49:05 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 04076212CC; Tue, 31 Mar 2020 17:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585676945; bh=7YB6ND8mrDeGDIhLt1OHuowTw1wah86m08QhZkfLdrg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=cYgWjwN1R88kTK3yT2gG1k3SpiZ9Vz0fYzWRtS56ooUUeRv4wJ+zDEmlu3P8LJOWP h8OEYSp4AikI9nTg/2BD2m4OiX2DEGbbakpNo75tOVvcmM9QGxkB+itppGyk5tKydr bh3+XF8WM7K0qL2ikOs7IigsYlsGE+HIoUSRWE8Q= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 72EED35226C3; Tue, 31 Mar 2020 10:49:04 -0700 (PDT) Date: Tue, 31 Mar 2020 10:49:04 -0700 From: "Paul E. McKenney" To: Uladzislau Rezki Cc: Joel Fernandes , 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 , Steven Rostedt Subject: Re: [PATCH RFC] rcu/tree: Use GFP_MEMALLOC for alloc memory to free memory pattern Message-ID: <20200331174904.GN19865@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200331131628.153118-1-joel@joelfernandes.org> <20200331140433.GA26498@pc636> <20200331150911.GC236678@google.com> <20200331160119.GA27614@pc636> <20200331170232.GA28413@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331170232.GA28413@pc636> 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 Tue, Mar 31, 2020 at 07:02:32PM +0200, Uladzislau Rezki wrote: > > > > > > 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. > > > Just adding more thoughts about such concern. Even though in theory we > can run into something like that. But also please note, that under high > memory pressure it also does not mean that (X) will always succeed with > further infinite allocations, so memory pressure is something common. > As soon as the situation becomes slightly better we do our work much > efficient. > > Practically, i was trying to simulate memory pressure to hit synchronize_rcu() > on my test system. By just simulating head-less freeing(for any object) and > by always dynamic attaching path. So i could trigger it, but that was really > hard to achieve and it happened only few times. So that was not like a constant > hit. What i got constantly were: > > - System got recovered and proceed with "normal" path; > - The OOM hit as a final step, when the system is run out of memory fully. > > So, practically i have not seen massive synchronize_rcu() hit. Understood, but given the attractive properties of headless kfree_rcu(), it is not unreasonable to expect its usage to remain low. In addition, memory-pressure scenarios can be quite involved. Finally, as Joel pointed out offlist, the per-CPU cached structure acts as a small portion of kfree_rcu()-specific reserved memory, so you guys have at least partially addressed parts of my concerns already. I am not at all a fan of using GFP_MEMALLOC because kfree_rcu() is sufficiently low-level to be in the business of ensuring its own forward progress. Thanx, Paul