Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp886819ybb; Wed, 1 Apr 2020 11:27:32 -0700 (PDT) X-Google-Smtp-Source: APiQypKUijiviZwP+k+ow2VnuE8aWqxVTfGeyMUrBcZiMGqzxXvgbKFpExx7hV/HYS/aFD+6gnqV X-Received: by 2002:aca:edcf:: with SMTP id l198mr3752196oih.97.1585765652337; Wed, 01 Apr 2020 11:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585765652; cv=none; d=google.com; s=arc-20160816; b=Rs9rMZ9HBrGCO2Qm4nkQV9x7Y0kueClolscu0BVoiwTyCfiDLYP4r/Hald2Spwjg+p 7pz2OYaUSz2+3catLV6pVtR4I+knAVK626jZZQHgKGM0deMrVXilMCaM0zTs5li9ZiON svRMdPvhh4Vop9xeNvtb8sELqjmnFsNhz3AXdA9Odil6h48z0Bmz/UhOwQgQECN7+sI5 j+AZFxj6enTHsu2SMuuI8p1+BRG+UCBNGHpWuuR58mFEFgia8yZqzT9WMpbtKQf+8aBj veKKgPXGbKPKSYN84+U+QmcP8aovM6fO9ZNJ0YErnad7m5PAdxwsblMBWfWm6JFdUbsF OoOg== 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=wFUQsfYfhRBXzwUIjPRExLbP3/+p8kB2nx68jHn0+08=; b=d9AX7P934Mt4oWwjDW2v/BwVb8plCWbKAlpgjA/CRkMCXEQOVSDnUaACQrpwBr535p mJvKpLVqG7mTmM5P2Q6t+ggzawkT4vfO784eKPFu/+LiFZ42RJim513GhmvVT1Pezxbv 9HuMLcSzLwwI0DugRwOH8kSZMF2DVakExzSnPXbVVSYwrNkJw3qcWXbocn9nUg3nF9ym uxxws1roNDfCGpSllPDa2O3fUG1zwSJnXIpfBP3kzTqLw59DMh2HtD36RQYzVwBHNEfN UpT1Phntt1Uk5tCc+dHQb5AMNblTbM165vg3V/d6S0D/f+DU4ICGfemWN0TN3OdkmaHQ 9SDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IClBs5dY; 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 n24si1171496otr.217.2020.04.01.11.27.20; Wed, 01 Apr 2020 11:27:32 -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=IClBs5dY; 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 S1732879AbgDAS0R (ORCPT + 99 others); Wed, 1 Apr 2020 14:26:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:48652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732316AbgDAS0R (ORCPT ); Wed, 1 Apr 2020 14:26:17 -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 3126720787; Wed, 1 Apr 2020 18:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585765576; bh=g5rW8mNTdi3VagM9mgwi86mVK6L7YuGisX9m9WlMVeM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=IClBs5dYySQ82cb01rO7lAJp3sYnbRIgHn0i5zmMl60flqGa447whUZtMaHtPgVWO w2ZHoy+n0AkoNDyFdo8QpqFtYndJ7vkGQ7aNcVfrwyh8bwDPafD9gDGQS9XlRDe+gV pDf2eUunVwpK5YZp6RttIN40h/4WqQrtOcNkRhsE= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id BA12235226B3; Wed, 1 Apr 2020 11:26:15 -0700 (PDT) Date: Wed, 1 Apr 2020 11:26:15 -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: <20200401182615.GE19865@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> <20200331183000.GD236678@google.com> <20200401122550.GA32593@pc636> <20200401134745.GV19865@paulmck-ThinkPad-P72> <20200401181601.GA4042@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401181601.GA4042@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 Wed, Apr 01, 2020 at 08:16:01PM +0200, Uladzislau Rezki wrote: > > > > > > > > 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. > > > > There are advantages and disadvantages either way. The advantage of the > > per-CPU pool is that you don't have to worry about something like lock > > contention causing even more pain during an OOM event. One potential > > problem wtih the per-CPU pool can happen when callbacks are offloaded, > > in which case the CPUs needing the memory might never be getting it, > > because in the offloaded case (RCU_NOCB_CPU=y) the CPU posting callbacks > > might never be invoking them. > > > > But from what I know now, systems built with CONFIG_RCU_NOCB_CPU=y > > either don't have heavy callback loads (HPC systems) or are carefully > > configured (real-time systems). Plus large systems would probably end > > up needing something pretty close to a slab allocator to keep from dying > > from lock contention, and it is hard to justify that level of complexity > > at this point. > > > > Or is there some way to mark a specific slab allocator instance as being > > able to keep some amount of memory no matter what the OOM conditions are? > > If not, the current per-CPU pre-allocated cache is a better choice in the > > near term. > > > As for mempool API: > > mempool_alloc() just tries to make regular allocation taking into > account passed gfp_t bitmask. If it fails due to memory pressure, > it uses reserved preallocated pool that consists of number of > desirable elements(preallocated when a pool is created). > > mempoll_free() returns an element to to pool, if it detects that > current reserved elements are lower then minimum allowed elements, > it will add an element to reserved pool, i.e. refill it. Otherwise > just call kfree() or whatever we define as "element-freeing function." Unless I am missing something, mempool_alloc() acquires a per-mempool lock on each invocation under OOM conditions. For our purposes, this is essentially a global lock. This will not be at all acceptable on a large system. Thanx, Paul > > If not, the current per-CPU pre-allocated cache is a better choice in the > > near term. > > > OK. I see your point. > > Thank you for your comments and view :) > > -- > Vlad Rezki