Received: by 10.192.165.156 with SMTP id m28csp714738imm; Mon, 16 Apr 2018 07:35:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/I50HwWOWMYM66qO+4obSFVp7OCKmcqXjJeyAO6PxTXQjpUwjHQ7ezvFLSygYgJTc1/PHX X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr15865733pls.109.1523889326696; Mon, 16 Apr 2018 07:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523889326; cv=none; d=google.com; s=arc-20160816; b=cskyJMZjML/wg9JKfuUQ3cDTaFpVvup+njVTi6kaw3t0uWBYwBX3y/m8Nc/erX3VIU MMKolPPssR+vNk20mmEruvTfw2R2zVCwqbuIEZo/I4/KiwGQQ9ncCpUT1vL7U090AO5p 4iv2k1Dy0pxj/O5enuiKoba5trcSZ4hOH611jLQbtHsH/i0zIBTrSCllrP7T8W/KngPB Et3gywEwLTWNTTaaySGquk53NeIm1iCR9v3aU4PtDY21DpiIRU2kuYi4dQxt+HVV4m1D mjrgQQqb+1MtCKyog0FpRE383xjxxZCdBVOQesIO1UTAOm8iZUso6ffFB2PiU+8tsYi6 RPsg== 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:arc-authentication-results; bh=pxfaZwX6MurStGOYfXQThLsudJCCu4IkT+EVONCUY7A=; b=0oKq2f3sx+f5c1qnYrjKkpYmGtlJP5St9+i+eeR9KU8Xaa/lszhzu3ljIBfTvchqKh r4QZYmeZDfovI0jxBqzKPmmm/+Ee1pEYJrmal9bZpJd/pksbZ8+yllBClwlE3iqVDqJ0 ZlleaaBenBaEnl3pvtRLsBhC+dI1C/0l3yh3Oc/fP/eSK+NeU3a1iWKuqlMkqR/j1Bxb 0mTNBqeeEEafJHRBjpfaJc/TU6POVxkd6kBHV47/yzBHWN8/Ht95b+tqIzNfmF3sPPSg Bnp48HNr378rybQX3hKM7xdGQIsNke3mfi6QVPj4C4pDnyZ9T2XxFbSrSu9go2/WNrIl eRXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=srdpY4OU; 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 b70si8274269pfd.153.2018.04.16.07.35.11; Mon, 16 Apr 2018 07:35:26 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=srdpY4OU; 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 S1754868AbeDPNJt (ORCPT + 99 others); Mon, 16 Apr 2018 09:09:49 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41456 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753530AbeDPNJm (ORCPT ); Mon, 16 Apr 2018 09:09:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pxfaZwX6MurStGOYfXQThLsudJCCu4IkT+EVONCUY7A=; b=srdpY4OUqJyDKKaV/xts2aqCz EJr8lIgY9si4VlacU8WuDQlK68JkKBI2lRL1ei6JypRSWMkTTl4Y5RgHxHu+esWhDXWWrXJ9MzH/f 98430C4C7U0cMyqZMUheCGWGB9Yv8XaH/XqvPe2/QsWIXeB7O4H75MGywsF3iuWkONEisZCLbmW6x l7c72RTw56U5NyAE9Mwp/my363wMAuBGlryts5xXvL0cbDzNEVj4R9Pkw/NXBYs3Yo+Ti/Uq8+tAP cJ0/fI9/asLVr89YRc26qkW3TF8Ok8TNbQi8nlQplRRBhLKmf6wrhFJ28D186Q8JEWkLoUIexyN/c WNzPuVlVw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f83t2-0007yd-FW; Mon, 16 Apr 2018 13:09:36 +0000 Date: Mon, 16 Apr 2018 06:09:36 -0700 From: Matthew Wilcox To: Vlastimil Babka Cc: Michal Hocko , Johannes Weiner , Minchan Kim , Roman Gushchin , linux-mm@kvack.org, Andrew Morton , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 3/3] dcache: account external names as indirectly reclaimable memory Message-ID: <20180416130936.GC26022@bombadil.infradead.org> References: <20180305133743.12746-1-guro@fb.com> <20180305133743.12746-5-guro@fb.com> <20180413133519.GA213834@rodete-laptop-imager.corp.google.com> <20180413135923.GT17484@dhcp22.suse.cz> <13f1f5b5-f3f8-956c-145a-4641fb996048@suse.cz> <20180413142821.GW17484@dhcp22.suse.cz> <20180413143716.GA5378@cmpxchg.org> <20180416114144.GK17484@dhcp22.suse.cz> <1475594b-c1ad-9625-7aeb-ad8ad385b793@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1475594b-c1ad-9625-7aeb-ad8ad385b793@suse.cz> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 02:06:21PM +0200, Vlastimil Babka wrote: > On 04/16/2018 01:41 PM, Michal Hocko wrote: > > On Fri 13-04-18 10:37:16, Johannes Weiner wrote: > >> On Fri, Apr 13, 2018 at 04:28:21PM +0200, Michal Hocko wrote: > >>> On Fri 13-04-18 16:20:00, Vlastimil Babka wrote: > >>>> We would need kmalloc-reclaimable-X variants. It could be worth it, > >>>> especially if we find more similar usages. I suspect they would be more > >>>> useful than the existing dma-kmalloc-X :) > >>> > >>> I am still not sure why __GFP_RECLAIMABLE cannot be made work as > >>> expected and account slab pages as SLAB_RECLAIMABLE > >> > >> Can you outline how this would work without separate caches? > > > > I thought that the cache would only maintain two sets of slab pages > > depending on the allocation reuquests. I am pretty sure there will be > > other details to iron out and > > For example the percpu (and other) array caches... > > > maybe it will turn out that such a large > > portion of the chache would need to duplicate the state that a > > completely new cache would be more reasonable. > > I'm afraid that's the case, yes. I'm not sure it'll be so bad, at least for SLUB ... I think everything we need to duplicate is already percpu, and if we combine GFP_DMA and GFP_RECLAIMABLE into this, we might even get more savings. Also, we only need to do this for the kmalloc slabs; currently 13 of them. So we eliminate 13 caches and in return allocate 13 * 2 * NR_CPU pointers. That'll be a win on some machines and a loss on others, but the machines where it's consuming more memory should have more memory to begin with, so I'd count it as a win. The node partial list probably wants to be trebled in size to have one list per memory type. But I think the allocation path only changes like this: @@ -2663,10 +2663,13 @@ static __always_inline void *slab_alloc_node(struct kmem _cache *s, struct kmem_cache_cpu *c; struct page *page; unsigned long tid; + unsigned int offset = 0; s = slab_pre_alloc_hook(s, gfpflags); if (!s) return NULL; if (s->flags & SLAB_KMALLOC) offset = flags_to_slab_id(gfpflags); redo: /* * Must read kmem_cache cpu data via this cpu ptr. Preemption is @@ -2679,8 +2682,8 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, * to check if it is matched or not. */ do { - tid = this_cpu_read(s->cpu_slab->tid); - c = raw_cpu_ptr(s->cpu_slab); + tid = this_cpu_read((&s->cpu_slab[offset])->tid); + c = raw_cpu_ptr(&s->cpu_slab[offset]); } while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != READ_ONCE(c->tid))); > > Is this worth exploring > > at least? I mean something like this should help with the fragmentation > > already AFAIU. Accounting would be just free on top. > > Yep. It could be also CONFIG_urable so smaller systems don't need to > deal with the memory overhead of this. > > So do we put it on LSF/MM agenda? We have an agenda? :-)