Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2979327pxm; Mon, 28 Feb 2022 09:38:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJoE57/X7x8Hh8P10ndKGwjxBojc6s1woF178e/WueaAuHYA3xD+/L+7WAuNjlcN3yc6l1 X-Received: by 2002:a17:902:cec3:b0:14f:f2e3:df52 with SMTP id d3-20020a170902cec300b0014ff2e3df52mr20784771plg.64.1646069884158; Mon, 28 Feb 2022 09:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646069884; cv=none; d=google.com; s=arc-20160816; b=WUX/gccbc9Fh+nZ3H3KvyOBn9oYZx9JH3Xk3Rp9Rx/9Y/PXfvlx2dokt4M6LDtDBoR Fl7Pa7VFzqZKr8RQ4thuJq7wNcKbJqozJPTBapBe8ZgBtupyKfr2Xs0WmyF4PKhrZ7zY T2Z76115EmPEXSuL4OVovOtYu0AuigTA0w2gLAZqsXkmzvRDUGPxRm5MVMQIMda4Jdxc flKweZB48UruFFPB/VCceHkBBFT+0wqnHBRZhjOFpitYxWIUjV3x4SfiH9kGqk5Uakp1 7qF68Su4RiLdLgCakEMSOAcd5vElBIZ8Bk0qtfGt+8Z8iqwuuVoUAk+sQ6ABcc5CSPz9 jykg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XfmIhW9nefMDb0zDTmGJWtqR+tWEq/czupXA0KsLpuU=; b=S5ExyjJfCScUyAa61DpBKbLxBB7LWZADHHU+3dfiWL//dNIBcElDYyAMsS1dxs8jNP 8DmpqW3YN5LZucTy0r8GYLzCfRrQ9hq6NUnTXr/mnmu5N6g+edgqxS1ZAR1y0dMEZhkC SH6CkrMMbzZ09Dw0SYPOGh5LNZNBb+4ZsWHFxPZvtebsVR4+7B3sv8C+yn+mOaEoJV8n HyQHy829yoHPL5YMG7srHEdEg0Vb8OwYciwBVaozzA10isIT8PDWyPBO5crqyz+3zJPn cf8f4x5WN7NoJe6gdfSXejG50WTZNmAEpbWb5EIbZplg3svwKMwJH5h9oxFXBRfNnTPt 8aWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qbmDJRUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a17090a550200b001bd43c5e0c9si21165pji.80.2022.02.28.09.37.47; Mon, 28 Feb 2022 09:38:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qbmDJRUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237180AbiB1ObL (ORCPT + 99 others); Mon, 28 Feb 2022 09:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237184AbiB1ObI (ORCPT ); Mon, 28 Feb 2022 09:31:08 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A9467EB33; Mon, 28 Feb 2022 06:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XfmIhW9nefMDb0zDTmGJWtqR+tWEq/czupXA0KsLpuU=; b=qbmDJRUut1QJorb6OhzfhKehG0 JIALb8xpWSL+u2jovi++1IazK9pdTw8LlGUTLVjmcJ01rc2Hhyx9WJLwvCoYJWi39huunsIdMnMvU 4h2MWso+ADY41rCVoK4w4GBj2iaP9ADHe77DbBAU7pI6J+tndzHONKwgdkvktgX2za+dd5wtIMdcl NBFzPCEnS6If7LMQ6NoyEJz7EJG9dN4X5jUyeTc0NE0XmE+l83nSQuTdndlRHEP8hz68MI/nUyUbW gSd3zugZEtHmmU+6zwHAD7B/xHKPQTNG9ylSqU9C6U99rcerieNDO1XynItF+BQ/f93DXeatpwcg0 tZGakbbA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOh2R-008bVC-QB; Mon, 28 Feb 2022 14:30:11 +0000 Date: Mon, 28 Feb 2022 14:30:11 +0000 From: Matthew Wilcox To: Marco Elver Cc: Kees Cook , llvm@lists.linux.dev, Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , linux-mm@kvack.org, stable@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Christoph Lameter , Nathan Chancellor , Nick Desaulniers , Daniel Micay , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mm: Handle ksize() vs __alloc_size by forgetting size Message-ID: References: <20220225221625.3531852-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 28, 2022 at 12:24:51PM +0100, Marco Elver wrote: > 2. Somehow statically computing the size-class's size (kmalloc_index() > might help here), removing __alloc_size from allocation functions and > instead use some wrapper. I don't think that's computable. I have been thinking about a slab flag that would say "speed is more important than size; if the smallest slab for this size of allocation has no free objects, search larger slabs to get memory instead of allocating a new slab". If we did have such a feature, it would be impossible to know how large ksize() would report.