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 0EE1DD3B9A4 for ; Tue, 26 Nov 2024 15:27:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5697C6B0082; Tue, 26 Nov 2024 10:27:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 519716B0085; Tue, 26 Nov 2024 10:27:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 377466B0082; Tue, 26 Nov 2024 10:27:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 182D06B0082 for ; Tue, 26 Nov 2024 10:27:29 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B45AA160AF6 for ; Tue, 26 Nov 2024 15:27:28 +0000 (UTC) X-FDA: 82828625334.02.96CAA50 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 9CE9E8000D for ; Tue, 26 Nov 2024 15:27:17 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=t6ZbDx2i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XtWgePsm; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rHgs3+NI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="KIoAM/tv"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732634842; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=A4DgMpMQcHaicV7qzhrooFxm0LSeTCsYPO16RJiC4qg=; b=GWC2XolXcowGJ5HyIF+0nd7FuvMiiPl14PGqzbq1X2CJyUUdqemN0hU1p6cQCoRqbpzmHC wTHcRpgCbgIydX6+hZIbj9WcTkv3NQm926K0i02X6K4x8Oucstbltu5FBSeufWD/1xBPXm QAoB7aGKGi/fVFuD+iHif3SmZ7LJ6kY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=t6ZbDx2i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XtWgePsm; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rHgs3+NI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="KIoAM/tv"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732634842; a=rsa-sha256; cv=none; b=JEHEadKJqFwowNpcQkY/DkkOZ4CRdz0CzKvz4o3KjWMjknj3sLrqtwepb0V9eEjrIH02PB +BKn5nfk/Y7M92MSwyRtFzLhyJcy2lwfnqAjCSmf2uFOAlRaM6dZxNqBM5HaSlDtBo45TB 20EySC47sjI17n4OE+2nAJ++e8ydgs8= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 575851F750; Tue, 26 Nov 2024 15:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732634844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=A4DgMpMQcHaicV7qzhrooFxm0LSeTCsYPO16RJiC4qg=; b=t6ZbDx2ibBq1e4VBUC6DyCWZ2pvireqPfUiThJvGkB5rELQfkB9SH098rSoiY3Pvg9pSVJ EqQdfbJp/LpIPwUl0rBHoLqUUbHHfAVOsHf9rNuPpcSVGn0JXROm5YJg/54obdiF//QJUI MCvgXHYBAF0URDk/dKW9w3727HiEQsc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732634844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=A4DgMpMQcHaicV7qzhrooFxm0LSeTCsYPO16RJiC4qg=; b=XtWgePsmHo7rfNDVokizDxEbzJ9droo45bx9L0YWNE8fiQWOE711bzTww5RXWH0oIrKpFP gIjgYJ7S3MjCS0Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732634843; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=A4DgMpMQcHaicV7qzhrooFxm0LSeTCsYPO16RJiC4qg=; b=rHgs3+NIo8CPXI2oFtvzxcAcdL8IvY1qmwfOBjbSR4uZgykFcJW5jT2qZeoeFDX7GCN0Y4 05o8lBD8QLrceSmPQLs+Gb9WO0lH6S0+yYoWXFJ2xZnisPTpOd5WCDM9cv3FZHENFFmyIG nFT5TGGLIfA8nL+LsYVxJVOatzFj7Aw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732634843; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=A4DgMpMQcHaicV7qzhrooFxm0LSeTCsYPO16RJiC4qg=; b=KIoAM/tvmqigLgesJpTKmgvd4GWB/gMjZ2B95kP9uqX4F2i6Pk3GbIqwZRe0GViDq/GR3z 356jou0xnkvlQUAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 41A4013890; Tue, 26 Nov 2024 15:27:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id V7GdD9voRWfCDAAAD6G6ig (envelope-from ); Tue, 26 Nov 2024 15:27:23 +0000 Message-ID: <36577539-bff6-476e-8d6b-ca20e3de2391@suse.cz> Date: Tue, 26 Nov 2024 16:27:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm/slab: Avoid build bug for calls to kmalloc with a large constant Content-Language: en-US From: Vlastimil Babka To: Ryan Roberts , Dave Kleikamp , Andrew Morton , Christoph Lameter , David Rientjes , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> <20241014105912.3207374-6-ryan.roberts@arm.com> <44312f4a-8b9c-49ce-9277-5873a94ca1bb@oracle.com> <7fb6c5a2-b9ae-4a29-a871-2f0bdc636e41@arm.com> <9675f4f0-6290-43aa-bf17-6b9c2b461485@suse.cz> <69746c3a-72af-4c28-8f04-bcfae7a78107@arm.com> Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PsLBlAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJPp+fMgqZkBQJkBREIBQkRadznAAoJECJPp+fMgqZkNxIQ ALZRqwdUGzqL2aeSavbum/VF/+td+nZfuH0xeWiO2w8mG0+nPd5j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mZOJGEACOKABgo9wJXsbWhGWYO7mD 8R8mUyJHqbvaz+yTLnvRwfe/VwafFfDMx5GYVYzMY9TWpA8psFTKTUIIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9CE9E8000D X-Stat-Signature: 1oqj814q4fc58ftupqsx5rsxa58y754n X-Rspam-User: X-HE-Tag: 1732634837-722507 X-HE-Meta: U2FsdGVkX1+VQ4Q2l2jCDtm8FwdmxuiVsTiB25ildeEJOoUuRFeCbsYU1t0Wku8m2Z/p5WYQojarZx5YWoadBgwu5XXshnaXKhY1LpxC2J0rjSqttZktZe6dzi3TbWnaO84wxL8UaTaS1Smk9FRYgLTQBWj5xZyMBlvxZ2klsx8GVIc0mwVRIo1D9MFThKgNRIJxKgC9o0M2N/QiJ7d3rJ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fwtoKcASIaSHltMw34VVDFwLOzqd2ze0oepHZfEmMzc2zSegw8lvQShmFhSItUFAvGAR2bY6BbEPHtU= 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: List-Subscribe: List-Unsubscribe: On 11/26/24 16:09, Vlastimil Babka wrote: > On 11/26/24 15:53, Ryan Roberts wrote: >> On 26/11/2024 12:36, Vlastimil Babka wrote: >>> On 11/26/24 13:18, Ryan Roberts wrote: >>>> On 14/11/2024 10:09, Vlastimil Babka wrote: >>>>> On 11/1/24 21:16, Dave Kleikamp wrote: >>>>>> When boot-time page size is enabled, the test against KMALLOC_MAX_CACHE_SIZE >>>>>> is no longer optimized out with a constant size, so a build bug may >>>>>> occur on a path that won't be reached. >>>>> >>>>> That's rather unfortunate, the __builtin_constant_p(size) part of >>>>> kmalloc_noprof() really expects things to resolve at compile time and it >>>>> would be better to keep it that way. >>>>> >>>>> I think it would be better if we based KMALLOC_MAX_CACHE_SIZE itself on >>>>> PAGE_SHIFT_MAX and kept it constant, instead of introducing >>>>> KMALLOC_SHIFT_HIGH_MAX only for some sanity checks. >>>>> >>>>> So if the kernel was built to support 4k to 64k, but booted as 4k, it would >>>>> still create and use kmalloc caches up to 128k. SLUB should handle that fine >>>>> (if not, please report it :) >>>> >>>> So when PAGE_SIZE_MAX=64K and PAGE_SIZE=4K, kmalloc will support up to 128K >>>> whereas before it only supported up to 8K. I was trying to avoid that since I >>>> assumed that would be costly in terms of extra memory allocated for those higher >>>> order buckets that will never be used. But I have no idea how SLUB works in >>>> practice. Perhaps memory for the cache is only lazily allocated so we won't see >>>> an issue in practice? >>> >>> Yes the e.g. 128k slabs themselves will be lazily allocated. There will be >>> some overhead with the management structures (struct kmem_cache etc) but >>> much smaller. >>> To be completely honest, some extra overhead might come to be when the slabs >>> are allocated ans later the user frees those allocations. kmalloc_large() >>> wwould return them immediately, while a regular kmem_cache will keep one or >>> more per cpu for reuse. But if that becomes a visible problem we can tune >>> those caches to discard slabs more aggressively. >> >> Sorry to keep pushing on this, now that I've actually looked at the code, I feel >> I have a slightly better understanding: >> >> void *kmalloc_noprof(size_t size, gfp_t flags) >> { >> if (__builtin_constant_p(size) && size) { >> >> if (size > KMALLOC_MAX_CACHE_SIZE) >> return __kmalloc_large_noprof(size, flags); <<< (1) >> >> index = kmalloc_index(size); >> return __kmalloc_cache_noprof(...); <<< (2) >> } >> return __kmalloc_noprof(size, flags); <<< (3) >> } >> >> So if size and KMALLOC_MAX_CACHE_SIZE are constant, we end up with this >> resolving either to a call to (1) or (2), decided at compile time. If >> KMALLOC_MAX_CACHE_SIZE is not constant, (1), (2) and the runtime conditional >> need to be kept in the function. >> >> But intuatively, I would have guessed that given the choice between the overhead >> of keeping that runtime conditional vs keeping per-cpu slab caches for extra >> sizes between 16K and 128K, then the runtime conditional would be preferable. I >> would guess that quite a bit of memory could get tied up in those caches? >> >> Why is your preference the opposite? What am I not understanding? > > +CC more slab people. > > So the above is an inline function, but constructed in a way that it should, > without further inline code, become > - a call to __kmalloc_large_noprof() for build-time constant size larger > than KMALLOC_MAX_CACHE_SIZE > - a call to __kmalloc_cache_noprof() for build-time constant size smaller > than KMALLOC_MAX_CACHE_SIZE, where the cache is picked from an array with > compile-time calculated index > - call to __kmalloc_noprof() for non-constant sizes otherwise > > If KMALLOC_MAX_CACHE_SIZE stops being build-time constant, the sensible way > to handle it would be to #ifdef or otherwise compile out away the whole "if > __builtin_constant_p(size)" part and just call __kmalloc_noprof() always, so > we don't blow the inline paths with a KMALLOC_MAX_CACHE_SIZE check leading > to choice between calling __kmalloc_large_noprof() or __kmalloc_cache_noprof(). Or maybe we could have PAGE_SIZE_MAX derived KMALLOC_MAX_CACHE_SIZE_MAX behave as the code above currently does with KMALLOC_MAX_CACHE_SIZE, and additionally have PAGE_SIZE_MIN derived KMALLOC_MAX_CACHE_SIZE_MIN, where build-time-constant size larger than KMALLOC_MAX_CACHE_SIZE_MIN (which is a compile-time test) is redirected to __kmalloc_noprof() for a run-time test. That seems like the optimum solution :) > I just don't believe we would waste so much memory with caches the extra > sizes for sizes between 16K and 128K, so would do that suggestion only if > proven wrong. But I wouldn't mind it that much if you chose it right away. > The solution earlier in this thread to patch __kmalloc_index() would be > worse than either of those two alternatives though.