Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3588940ybe; Sun, 15 Sep 2019 19:32:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqygVvpWjzoGWWQQeDYy+B4Uk1cL7HGGnhEhzXja9GsXiCtF3cRYzrbz9GafmIYCbOC+tAtD X-Received: by 2002:a17:906:5246:: with SMTP id y6mr21751515ejm.158.1568601169497; Sun, 15 Sep 2019 19:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568601169; cv=none; d=google.com; s=arc-20160816; b=Phx193oAzjoA4yAKGXjWc7UhV6nhgAwNdkdZ+sjjWZis3KhrwScTmzgkgzbIF3hmW9 dOVA262gezgsa9eOjKo+6arLWpJbvBu2znlnnk2DdJAfc1gjEFTzqt50ngtA4JA7jha/ c1PMUVK6Z4+HF94lc6rnUD3Qtb6MBNh/4jezg2c0GehJd4TJTjTCrWLaKtbd8tmB/XaK qgdljrx529CS6Od5cN/oW4xf6+3JnXaBOUVMiACgtapY69uExGoBD/gdnYQFaDWn97i4 Xezrfa+NXLWN0km6rSG8/H2CClFs4F3HnifoBDRAD5J9tht541eHyU3ojPqdKSKMsF8n bnaQ== 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:dkim-signature; bh=h/ncaV79w3xY6uDWRhXLpEpTfQJmu4P1Z2vnPyRUpIA=; b=PzAVhAM7tljntoD7fU6QJLxja/79qDhjWjQdk6MjXyTSIev4QLjbLt9ACWCjEaIyVo KUQchjKecYeeHnN4kV+6Qp0JSFurHrehe7fhILP60vQIYY9rBnt2w4H3uwfwU/ocIJOx iNch8YLLhkOZtxaWz1WFM4EhkqTHgKST1CDWAvEL7FZhMcq4EYy0tlvvK+vRIkk07ZOT Sgj4ToBC57j06lTJ6T0uLbvkc8Opkc0kHRSPqzxT80n5faUv0s7q6UGH4jSunwwQPkzq Vr8Xkcyf0V1JpfC8Q3Sik0QYtLdBqyBM7wmjI2HQL2t3KYttUFHU4mcB6yPRYaFK7NzE pxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=F1xoMG61; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si18798585ejr.281.2019.09.15.19.32.25; Sun, 15 Sep 2019 19:32:49 -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=@google.com header.s=20161025 header.b=F1xoMG61; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728734AbfIOVin (ORCPT + 99 others); Sun, 15 Sep 2019 17:38:43 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44732 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728630AbfIOVik (ORCPT ); Sun, 15 Sep 2019 17:38:40 -0400 Received: by mail-pl1-f194.google.com with SMTP id k1so15878326pls.11 for ; Sun, 15 Sep 2019 14:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=h/ncaV79w3xY6uDWRhXLpEpTfQJmu4P1Z2vnPyRUpIA=; b=F1xoMG61RxtRCLXxjqDWYUm0394z6rD85HVnbn9F4gsb3b6dKZUs9ZjGFrY9c4ImFQ 1fLIlFzwuuyAwStdYmUlNMDXXLPNk7cpjjtxoTbPqFLI2nzdgsRuplCMLHccqnXBlsRt zPPAUujdo989SuLOVZdYzUjtT6YHBiz08XF/+p25bO/kOJ1PO6OPkLXLEap/lRNrmaSe DDSXYYdOv51j1IemdzFk2LfKF8FH8E8EitP1K2z/eoYuLkzT8Pitdv6hkjhH+EFmVRWl czAe17sRG2HvdbEXLERIcpiBgmBbUKDHXFD1gE/AKmwxXxeArRl9mOObvXfhsXV/FgQB kXRg== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=h/ncaV79w3xY6uDWRhXLpEpTfQJmu4P1Z2vnPyRUpIA=; b=obxMpWAAZN9V6RFwAv+IcrZ8Bmacz+SP5BwiWxEoKK3/TEG+jgjX8HXGjX0LG8vyO2 wjStO6QQPdN4ioAkrGI58h8t6P8d2u7DLDcNqGGYOFR3690OkJYRgdeT+IHbNKE0+p9e ZFqWD0T6IKYM483YuGmPQ2iznQCa7y87WJ0djmrFHXanFLmAWZOhF7Fs6zxp20Q4bswk XDJHdiT1ulFQ/HOK2WuDPIW+vDFXZNLZSYf+igGugnE0+CyOFRj0AJilGaN09vImfbIg /N5rP8/nDYXz4Mg9JZTHvYfR4kiK8mrgkyF0+Lcxof0aSb+ouc1MXstHWedtTB8F+FEt QaSw== X-Gm-Message-State: APjAAAV/NYk2MTo5M9YQeJQ2T8Z7DYzFOq5SDTsjJQyDENdS0JKIjePr 4JQI7mBQETEkD8TXpk++cidP6w== X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11mr59400191plb.93.1568583519068; Sun, 15 Sep 2019 14:38:39 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id v44sm21332300pgn.17.2019.09.15.14.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2019 14:38:38 -0700 (PDT) Date: Sun, 15 Sep 2019 14:38:37 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Pengfei Li cc: akpm@linux-foundation.org, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, guro@fb.com Subject: Re: [RESEND v4 6/7] mm, slab_common: Initialize the same size of kmalloc_caches[] In-Reply-To: <20190915170809.10702-7-lpf.vector@gmail.com> Message-ID: References: <20190915170809.10702-1-lpf.vector@gmail.com> <20190915170809.10702-7-lpf.vector@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) 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, 16 Sep 2019, Pengfei Li wrote: > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 2aed30deb071..e7903bd28b1f 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -1165,12 +1165,9 @@ void __init setup_kmalloc_cache_index_table(void) > size_index[size_index_elem(i)] = 0; > } > > -static void __init > +static __always_inline void __init > new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > { > - if (type == KMALLOC_RECLAIM) > - flags |= SLAB_RECLAIM_ACCOUNT; > - > kmalloc_caches[type][idx] = create_kmalloc_cache( > kmalloc_info[idx].name[type], > kmalloc_info[idx].size, flags, 0, > @@ -1185,30 +1182,22 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > void __init create_kmalloc_caches(slab_flags_t flags) > { > int i; > - enum kmalloc_cache_type type; > > - for (type = KMALLOC_NORMAL; type <= KMALLOC_RECLAIM; type++) { > - for (i = 0; i < KMALLOC_CACHE_NUM; i++) { > - if (!kmalloc_caches[type][i]) > - new_kmalloc_cache(i, type, flags); > - } > - } > + for (i = 0; i < KMALLOC_CACHE_NUM; i++) { > + if (!kmalloc_caches[KMALLOC_NORMAL][i]) > + new_kmalloc_cache(i, KMALLOC_NORMAL, flags); > > - /* Kmalloc array is now usable */ > - slab_state = UP; > + new_kmalloc_cache(i, KMALLOC_RECLAIM, > + flags | SLAB_RECLAIM_ACCOUNT); This seems less robust, no? Previously we verified that the cache doesn't exist before creating a new cache over top of it (for NORMAL and RECLAIM). Now we presume that the RECLAIM cache never exists. Can we just move a check to new_kmalloc_cache() to see if kmalloc_caches[type][idx] already exists and, if so, just return? This should be more robust and simplify create_kmalloc_caches() slightly more.