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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1612C4332F for ; Tue, 13 Dec 2022 14:03:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 739CB8E0003; Tue, 13 Dec 2022 09:03:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E9F88E0002; Tue, 13 Dec 2022 09:03:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58A188E0003; Tue, 13 Dec 2022 09:03:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 494678E0002 for ; Tue, 13 Dec 2022 09:03:01 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0182A120D42 for ; Tue, 13 Dec 2022 14:03:00 +0000 (UTC) X-FDA: 80237449362.18.9D1375A Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf16.hostedemail.com (Postfix) with ESMTP id 1311D180017 for ; Tue, 13 Dec 2022 14:02:57 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i191arES; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670940178; a=rsa-sha256; cv=none; b=33HLZAV3cC/fCTxQuL2BYLs1g+iGFaPb+wB7r5MdgVFMdb0o1wHm9N05IyY8u7jBHYjhKl aOYFVQBwJE08+ZDUimNQpMOYpMMhHPgSQ+wYDcc+Rx2h763fYtA+kPA8O6mj78o97Xy8ce rUMemklUv8M6es1SY7/XMXkB9KEqET0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i191arES; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670940178; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5YiSjWHoQWvxaPnMWkhQIQOkA+9eRIuJnwPdOS374zI=; b=zPqkeRMnz+WrbV0HkudTEdyDgxC+3bDAA3ApePQsNI/Qn9jV8z9dMsfeBG5TYDCyp+kN4X nffG1b9q7QC9S5trghVtfD1bNfscUnT4pBkbCBz4dLxHVruM4NT+GdFMwWXMouibrtFaSB Gu1GBlplndzHUmdZQxCyNDBQKnfTCMg= Received: by mail-pj1-f51.google.com with SMTP id fy4so3540900pjb.0 for ; Tue, 13 Dec 2022 06:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5YiSjWHoQWvxaPnMWkhQIQOkA+9eRIuJnwPdOS374zI=; b=i191arESYf3ytwMfFMtgeaKAS9H5vjtkaPCums6F5nmiiiXLgP6n3izOpIxcPDHuMa tGJT27K3n4zgHFtYDXQ/uuQ0wOOJJ8qYhZBSs2mJzJnZjInobNMYKb1uDZve++kIoQdO lrn3gZIlO83al62AO3fAseNoqtZc5KiGkccvYuPzzKc3Do0EUC0I/Yn/cB4q+xHGkiKF vYH/g7vgwp75Nw4Oi2NrBk/EDD4MKcjWRqiQbP0qGt+3Rlm5vOOWcYW3a5DrfIOlS/fT SlsuX6f+4sIX3TyQ6AS/tL6BrA0Wh8C4PE0exCBY4cX0amezW2ahyc/0eRcs7bfoOd6H 8L0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5YiSjWHoQWvxaPnMWkhQIQOkA+9eRIuJnwPdOS374zI=; b=EenxwTFxbkupW1oKuLnZ9dkaA84UbqpumXFawMtZSGxmM0RUN9UjEXAnRfZ2EQs72n OBFPPd6hQXnCyvhLB6k9hz9q5u5nDWV/h7Loj30P48VCVusPDwnYqN8QloQ4MeE2zyx9 Cb9JktzKoRNH2Kmlm5xc8XErRBY26PQ6pejQx7aRoXp1kwuEoIAr0wcKzBpvSk+Yi3FB H09pesMZWRApVmZWPeTVtFjFSCMVqqfmz2kCsfuie1FXuwdZjY0Euwp18CTQ0yAiTEvW 5k0VnFkgzdmpsHveWQ6EOt4AUakkf/W0SDJbXYKVACcqEPNXfbCBwlxcUNgJ8v8AmWmC NkkQ== X-Gm-Message-State: ANoB5pkbmg7XQLYDm+/YEXBj7MU8FAW/03hg4UKCpoBdI/zNft93ezF7 LUJXmMc4sbCO6a6OIx/LJQQ= X-Google-Smtp-Source: AA0mqf4ZPrtW54ww6Zvl6Ql4G2TELTlzGR4srjVLOEtRgpEOsxTRyyMe9EvHYVftTjcf85a6AR9rNw== X-Received: by 2002:a17:902:a588:b0:185:441e:90b5 with SMTP id az8-20020a170902a58800b00185441e90b5mr20420811plb.27.1670940176560; Tue, 13 Dec 2022 06:02:56 -0800 (PST) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id jh19-20020a170903329300b001811a197797sm8462259plb.194.2022.12.13.06.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 06:02:55 -0800 (PST) Date: Tue, 13 Dec 2022 23:02:49 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Baoquan He Cc: Dennis Zhou , Vlastimil Babka , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg , Roman Gushchin , Andrew Morton , Linus Torvalds , Matthew Wilcox , patches@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/12] mm, slub: remove percpu slabs with CONFIG_SLUB_TINY Message-ID: References: <20221121171202.22080-1-vbabka@suse.cz> <20221121171202.22080-11-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 1311D180017 X-Rspamd-Server: rspam01 X-Stat-Signature: 3esypn4udnttatd5o31ndupq5o5yauaw X-HE-Tag: 1670940177-963448 X-HE-Meta: U2FsdGVkX18uIL8Ip+thqT9/vH2NJHQ98LSU3XBHbN1OvMMpjeKsJjAabo7z1w0rN3LTB+AF8PoCaSz1KIfKxc5iRoiZaNejRA8qb7n2nhSsLbUZH56dUqTO+6SLNo8OAKlc0zpBZfxFYVHkZUdjQC/NtGgk5+JDkU5xaJr+1tTb7gsacQ2GZWGMPXzqK7WOfMIONGDMgpCIs6uDhPY0RVbZuGkzcdD43A3tc7n5z54/2MM4lUaYMjJh87Uqn7lWojcyIjpOZ4elipoJ3pK4FL9jq3CzznEt7MwVh5lbsGGloYr8l+5h4JEpPui5w8mA5HggQCvxJYQ8DxvjPa8ZbnAIe4UhhvxpxO97Wm9aCjXynNbEm8pjTDDhI1Y3E+6MW5bYUoxhWqj7IY1aVqHgK+7C5fBdyxFSIz54KaSKu9wh/lJy756dp16jO0Nsi1Sg0gpiC+AlsuJsvI0wxpEHzmYinWzaPJBxXBt4W+6y9GJBmHAjWKj3X1D3A8CVUl0r4ODGyNGMku7BoC4J7r8Gj4TkNHsT5rVtIdGNXynQDlRjDJZYACok5lK9RN0zgYQLJk4fty2IvvcSnztzhc5g8XOmzkeeGglbUnxYsH+hH3zYr31b83dYbM2TeUTgWuGene8rARThrY9Ef0N/t+JFipdfpOd6SCAlLHMHQCYdiM/lKss8plASPm4GBoIDAtV4NKjp/zd0QnGfJ/tTov3wJXOnmgRKr7HzaMw7mAwpoG/g5AHQ7uzhwjSg7nhSqq7+TjBW73e3Xowcln/DkaY8mEpXvXIjbm4M9driflSctqq9Krg1V/+0cf2FK3SC28V4Z/xQ9vSPN6J9oXv/FZwRep20FPBcbKWlKQvGgdcdhXjmsnIIKXsrijaaluY6PRL2IP2Ble0WPxocLGhz/vfEUGo5yDz2DoGG0d1xLN8B+5g0gWQOSuFyNWPGPdIH0MBJZI3/ZyxOSeKNzioNWoP JL2h8Htd zTXQ+3FpP3d0GhxBKa26yk02RGNNL4W0TzmiikcsaOmEl91WyZ9gdCuBqPFmwOBFMn4tQNV01qcyp9FjElotqIkoRgotuh0VSRFOTu1wJI9dHmRc6j9WiKzi0YvmBhanZdmRfxtT2GRqx0Osw8bI6/pIJ0ZUxFQVn3+HuzVymfYz4c64= 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 Tue, Dec 13, 2022 at 11:04:33AM +0800, Baoquan He wrote: > On 12/12/22 at 05:11am, Dennis Zhou wrote: > > Hello, > > > > On Mon, Dec 12, 2022 at 11:54:28AM +0100, Vlastimil Babka wrote: > > > On 11/27/22 12:05, Hyeonggon Yoo wrote: > > > > On Mon, Nov 21, 2022 at 06:12:00PM +0100, Vlastimil Babka wrote: > > > >> SLUB gets most of its scalability by percpu slabs. However for > > > >> CONFIG_SLUB_TINY the goal is minimal memory overhead, not scalability. > > > >> Thus, #ifdef out the whole kmem_cache_cpu percpu structure and > > > >> associated code. Additionally to the slab page savings, this reduces > > > >> percpu allocator usage, and code size. > > > > > > > > [+Cc Dennis] > > > > > > +To: Baoquan also. > > Thanks for adding me. > > > > > > > > Wondering if we can reduce (or zero) early reservation of percpu area > > > > when #if !defined(CONFIG_SLUB) || defined(CONFIG_SLUB_TINY)? > > > > > > Good point. I've sent a PR as it was [1], but (if merged) we can still > > > improve that during RC series, if it means more memory saved thanks to less > > > percpu usage with CONFIG_SLUB_TINY. > > > > > > [1] > > > https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/tag/?h=slab-for-6.2-rc1 > > > > The early reservation area not used at boot is then used to serve normal > > percpu allocations. Percpu allocates additional chunks based on a free > > page float count and is backed page by page, not all at once. I get > > slabs is the main motivator of early reservation, but if there are other > > users of percpu, then shrinking the early reservation area is a bit > > moot. > > Agree. Before kmem_cache_init() is done, anyone calling alloc_percpu() > can only get allocation done from early reservatoin of percpu area. > So, unless we can make sure nobody need to call alloc_percpu() before > kmem_cache_init() now and future. Thank you both for explaination. just googled and found random /proc/meminfo output of K210 board (6MB RAM, dual-core) Given that even K210 board uses around 100kB of percpu area, might not be worth thing to do :( https://gist.github.com/pdp7/0fd86d39e07ad7084f430c85a7a567f4?permalink_comment_id=3179983#gistcomment-3179983 > The only drawback of early reservation is it's not so flexible. We can > only dynamically create chunk to increase percpu areas when early > reservation is run out, but can't shrink early reservation if system > doesn't need that much. > > So we may need weigh the two ideas: > - Not allowing to alloc_percpu() before kmem_cache_init(); > - Keep early reservation, and think of a economic value for > CONFIG_SLUB_TINY. > > start_kernel() > ->setup_per_cpu_areas(); > ...... > ->mm_init(); > ...... > -->kmem_cache_init(); > > > __alloc_percpu() > -->pcpu_alloc() > --> succeed to allocate from early reservation > or > -->pcpu_create_chunk() > -->pcpu_alloc_chunk() > -->pcpu_mem_zalloc() > -- Thanks, Hyeonggon