From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF7F1C433E1 for ; Fri, 5 Jun 2020 16:24:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF4B52074B for ; Fri, 5 Jun 2020 16:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF4B52074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2EB9E80007; Fri, 5 Jun 2020 12:24:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29A848E0006; Fri, 5 Jun 2020 12:24:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18A1680007; Fri, 5 Jun 2020 12:24:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id F1CA18E0006 for ; Fri, 5 Jun 2020 12:24:36 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B6FD78016BDA for ; Fri, 5 Jun 2020 16:24:36 +0000 (UTC) X-FDA: 76895681352.21.story89_0d1344f26da1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 9DE731804460F for ; Fri, 5 Jun 2020 16:24:36 +0000 (UTC) X-HE-Tag: story89_0d1344f26da1 X-Filterd-Recvd-Size: 2515 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Jun 2020 16:24:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A90C5AC5F; Fri, 5 Jun 2020 16:24:37 +0000 (UTC) Subject: Re: [PATCH v5 17/19] mm: memcg/slab: use a single set of kmem_caches for all allocations To: Roman Gushchin , Andrew Morton , Christoph Lameter Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org References: <20200527223404.1008856-1-guro@fb.com> <20200527223404.1008856-18-guro@fb.com> From: Vlastimil Babka Message-ID: Date: Fri, 5 Jun 2020 18:24:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200527223404.1008856-18-guro@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9DE731804460F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 5/28/20 12:34 AM, Roman Gushchin wrote: > diff --git a/mm/slab.h b/mm/slab.h > index c49a863adb63..57b425d623e5 100644 > --- a/mm/slab.h > +++ b/mm/slab.h ... > @@ -526,8 +430,7 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x) > * When kmemcg is not being used, both assignments should return the > * same value. but we don't want to pay the assignment price in that > * case. If it is not compiled in, the compiler should be smart enough > - * to not do even the assignment. In that case, slab_equal_or_root > - * will also be a constant. > + * to not do even the assignment. > */ > if (!memcg_kmem_enabled() && Just realized that this test can go away - we don't have to call virt_to_cache() due to kmemcg if there is just a single cache. > !IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) && > @@ -535,7 +438,7 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x) > return s; > > cachep = virt_to_cache(x); > - WARN_ONCE(cachep && !slab_equal_or_root(cachep, s), > + WARN_ONCE(cachep && cachep != s, > "%s: Wrong slab cache. %s but object is from %s\n", > __func__, s->name, cachep->name); > return cachep;