Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp81927ybk; Fri, 8 May 2020 14:37:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJ6Mh/vHMKJ3+SghccC+AN5Izp+genxYnKdeBons00ulgjEagj7OwPsQmxPBG0BnQ7alH6g X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr3978590edb.372.1588973870225; Fri, 08 May 2020 14:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588973870; cv=none; d=google.com; s=arc-20160816; b=x0DiAW50TApmEdKTNbWGROf+qVVAf3EoXVrdS5zb+9X/YpWasARD6UycCVbO0Z+4Mp d2Xd5RDyWscYtmJ7IrxWxPhCOrDq2mRRwMThK22CGMFA7hAuKIqsJ6X0ASa5/aG2I4Xr 7pEIiaF+0W8pBlialHjumsEBHKaYxXURQMls9rdN8uwJvT3HEsQVfXqbfHdj4EpGYNmQ 6XyWeFZaPQ3YRXWKK3bApv50E18P+L8tbCCd88wym0YeKHVE8yxZRJRPyszz+GQeDDOW xgm5ntLBEahqPeJeDsRyk3qry+AXZrvsWYQymTwPJKFBPBJtF90xe5hjnQL5+c39oYRL kSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=KKLkA2v68WfZ6KKYmuJVwsPiiXEeN1or/PgDAuvnkKI=; b=uXJvzxO0Xu1OdUx31S4Q38qp11A46BOqx+ugHpVXZGGCz1KoJGmdFz1ZHF2yF+isTr 0ViCs6NcWMnenO+6VTQKSuS75XBmuS4/MrPfiVmrBg58dRzow7An/h3kGa3Yu8po8ENo P05XsiqsxQLXf7GASXEwOCj3jA3x6EOUUKMr5UYQtluti6Ckkh6DORRNQaIkI77dKBvm 0vUdMjrCzFFe5wKuS8CuM5SgS2CPefzyjnKzvSDZlSIBtJ+QDlMNnfXVuxVqZJJGzj9k ZvZuyhZxkbPGbGIbnqmjL3v1jptR68Ortlrrjp5wY0CS77Inn6uRWIfjFyE3lOd9aBz0 +4cQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si1740850edy.578.2020.05.08.14.37.27; Fri, 08 May 2020 14:37:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbgEHVfz (ORCPT + 99 others); Fri, 8 May 2020 17:35:55 -0400 Received: from gentwo.org ([3.19.106.255]:33674 "EHLO gentwo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbgEHVfz (ORCPT ); Fri, 8 May 2020 17:35:55 -0400 Received: by gentwo.org (Postfix, from userid 1002) id 98CBA3FED9; Fri, 8 May 2020 21:35:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 9788F3ED24; Fri, 8 May 2020 21:35:54 +0000 (UTC) Date: Fri, 8 May 2020 21:35:54 +0000 (UTC) From: Christopher Lameter X-X-Sender: cl@www.lameter.com To: Roman Gushchin cc: Andrew Morton , Johannes Weiner , Michal Hocko , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/19] mm: slub: implement SLUB version of obj_to_index() In-Reply-To: <20200504182922.GA20009@carbon.dhcp.thefacebook.com> Message-ID: References: <20200422204708.2176080-5-guro@fb.com> <20200423000530.GA63356@carbon.lan> <20200425024625.GA107755@carbon.lan> <20200427164638.GC114719@carbon.DHCP.thefacebook.com> <20200430171558.GA339283@carbon.dhcp.thefacebook.com> <20200504182922.GA20009@carbon.dhcp.thefacebook.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 4 May 2020, Roman Gushchin wrote: > On Sat, May 02, 2020 at 11:54:09PM +0000, Christoph Lameter wrote: > > On Thu, 30 Apr 2020, Roman Gushchin wrote: > > > > > Sorry, but what exactly do you mean? > > > > I think the right approach is to add a pointer to each slab object for > > memcg support. > > > > As I understand, embedding the memcg pointer will hopefully make allocations > cheaper in terms of CPU, but will require more memory. And you think that > it's worth it. Is it a correct understanding? It definitely makes the code less complex. The additional memory is minimal. In many cases you have already some space wasted at the end of the object that could be used for the pointer. > Can you, please, describe a bit more detailed how it should be done > from your point of view? Add it to the metadata at the end of the object. Like the debugging information or the pointer for RCU freeing. > I mean where to store the pointer, should it be SLAB/SLUB-specific code > or a generic code, what do to with kmallocs alignments, should we > merge slabs which had a different size before and now have the same > because of the memcg pointer and aligment, etc. Both SLAB and SLUB have the same capabilities there. Slabs that had different sizes before will now have different sizes as well. So the merging does not change. > I'm happy to follow your advice and perform some tests to get an idea of > how significant the memory overhead is and how big are CPU savings. > I guess with these numbers it will be easy to make a decision. Sure. The main issue are the power of two kmalloc caches and how to add the pointer to these caches in order not to waste memory. SLAB has done this in the past by creating additional structues in a page frame.