Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6158652ybf; Thu, 5 Mar 2020 14:26:36 -0800 (PST) X-Google-Smtp-Source: ADFU+vtOJM8XeMB1z0z6aNeLjUge8HasSczqs9lK6uKGu8yz59nm8yBTalbesYwL02IVFOh07D1L X-Received: by 2002:aca:ad55:: with SMTP id w82mr448009oie.133.1583447196122; Thu, 05 Mar 2020 14:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583447196; cv=none; d=google.com; s=arc-20160816; b=fzVN58ynQBa7N+dO+349pORbDAyUSShjfRrv4OQ2jzvDm8W5k67JO/kTO6rlGBGmMX 86y6vhJyzbEF6/rvEx48AE8cCDfGgY2d0lXNfNzjikegXIYcKpg+we7Bt+QVijdr2LJI 2Nteb+2hGm3ezEJ/qw57+DlZx3B1uuYyhvkw8Y3/gc9mNcC7mMCYTMtTGRGtWYBKDNDz vXOy8wIVgTcQHRqndiLguDBoQ16uBbOffTQkoMDDs+50zQWfoWLWxTE4YXIvCnfZIkmK CGJrdyTW1Ezr6fQi5bw1PwsInf0qpaKuGWgv+za9cVQ4YanZ3R0QKUIh8WZMUtJfPXWA KOqQ== 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:from:date:dkim-signature; bh=DS3YcKqO0mcvZOjaCwu0fyqXymHyb+ZjqvrmGOweESY=; b=w6i1WAnp9bwaKiG3+elz5ArmXElQEXiSfv5J01c6wQnIOMeUDaekq5GL+XGHo71B4L 9y9sDwgvI+AdHeICHmxgSuv9rqCT0JpUW+tfLJY2lO7/yQt6mdenTy7ewpY/gB/T2Yt6 nM6CxxeEJwGZCyc6SYWX0qCVNlsBKSuT7oiZQWN30oBNVSQ6/XnI/+pFtXzyx0GrEhmg 6Mozv70qGBPcW6q1BP6klpA5YTZdOSwJMNdbjGKAYRvcVC0wjppNID9yVcFP6B9QheTG w+nVjRAYfkwlh5E3Xga+mAbExkvhjNKTInU8Ako+H/0VpSKEkEtIxpT7l91WJd9IxrJZ 9rrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=h0wbAKXu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c189si182483oig.205.2020.03.05.14.26.23; Thu, 05 Mar 2020 14:26:36 -0800 (PST) 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=@joelfernandes.org header.s=google header.b=h0wbAKXu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgCEW0B (ORCPT + 99 others); Thu, 5 Mar 2020 17:26:01 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:41097 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbgCEW0B (ORCPT ); Thu, 5 Mar 2020 17:26:01 -0500 Received: by mail-qk1-f193.google.com with SMTP id b5so462781qkh.8 for ; Thu, 05 Mar 2020 14:25:59 -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:user-agent; bh=DS3YcKqO0mcvZOjaCwu0fyqXymHyb+ZjqvrmGOweESY=; b=h0wbAKXuAqwo28k+L1LitMTs7AAC/dVZRZ2ITanvKFmMHIay2KcQrKUAHY3sE7abTX DcHRM3gVQZaSUpyYNLENY9/JOWsxRnBTGFpngQAUriNZhOBOC7/UYjW66aigFhvl29fV Tl+TyKlrgIiewIPKtGdZmt8rj93Ymk1zIkzHQ= 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:user-agent; bh=DS3YcKqO0mcvZOjaCwu0fyqXymHyb+ZjqvrmGOweESY=; b=U1KnKgRh/gtcXjxRd6ERbusRJ3Z3GWhgBxqT+wqBpIHFAAIJ2LRhOdreZyboAuysiE zWM9qHwVbRVGq6lEUkdjogFg1GJdmI//O280uEqLzjl3XqvMsC6EUINo/1u437zXZuK2 +YSZior30Suw4ygu/5L3Z5pl2kH3f+aYBUQA0PCyEmD9740oUDbeFIy7mp18WKTQKfqG bJPWv4RY+yYuUkWltPNFaUhMwEqaaEvrou1eTbzGF70OJgDVWaIHZ9NBF2wAoHL0YuLM UusQlQzCi8kBb7lmyw7atOzgfcHkOdmHyB9gGRanfQ/FUVEDbbW7KQ4tPLDVjIqdR6sB +Low== X-Gm-Message-State: ANhLgQ1t5q/H3spfrJ/Cki9ctM2JJLNe3zq0CKbhLNZ6lfndVQL/1rk+ Zd1YClEjQ3b59HEYKmTzhytzGi+LD8c= X-Received: by 2002:a37:4d10:: with SMTP id a16mr210869qkb.325.1583447158811; Thu, 05 Mar 2020 14:25:58 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id g1sm6910713qkl.55.2020.03.05.14.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 14:25:58 -0800 (PST) Date: Thu, 5 Mar 2020 17:25:57 -0500 From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: urezki@gmail.com, Davidlohr Bueso , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [PATCH linus/master 2/2] rcu/tree: Add a shrinker to prevent OOM due to kfree_rcu() batching Message-ID: <20200305222557.GC66450@google.com> References: <20200305221323.66051-1-joel@joelfernandes.org> <20200305221323.66051-2-joel@joelfernandes.org> <20200305221753.GA66450@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200305221753.GA66450@google.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2020 at 05:17:53PM -0500, Joel Fernandes wrote: > On Thu, Mar 05, 2020 at 05:13:23PM -0500, Joel Fernandes (Google) wrote: > > To reduce grace periods and improve kfree() performance, we have done > > batching recently dramatically bringing down the number of grace periods > > while giving us the ability to use kfree_bulk() for efficient kfree'ing. > > > > However, this has increased the likelihood of OOM condition under heavy > > kfree_rcu() flood on small memory systems. This patch introduces a > > shrinker which starts grace periods right away if the system is under > > memory pressure due to existence of objects that have still not started > > a grace period. > > > > With this patch, I do not observe an OOM anymore on a system with 512MB > > RAM and 8 CPUs, with the following rcuperf options: > > > > rcuperf.kfree_loops=20000 rcuperf.kfree_alloc_num=8000 > > rcuperf.kfree_rcu_test=1 rcuperf.kfree_mult=2 > > Paul, > I may have to rebase this patch on top of Vlad's kfree_bulk() work. But let > us discuss patch and I can rebase it and repost it once patch looks Ok to > you. (The kfree_bulk() work should not affect the patch). BTW, we can also use the scheme in the future to keep garbage uncollected until memory pressure. That way you defer grace periods for longer similar to the paper [1], until the MM layer thinks the party is over. For one, I am not too confident about the shrinker's ability to handle transient memory spikes. If I remember, the shrinker is best-effort. But one step at a time :) thanks, - Joel [1] https://dl.acm.org/doi/10.1145/3190508.3190522