Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp540836rdh; Thu, 23 Nov 2023 10:48:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD3dUgyXmcbFy91JpGMuNs5z/MmiNgDWhGu2a1nznOlvmFpWNg0DCrjXILGBsA9jajhINu X-Received: by 2002:a05:6a00:e0f:b0:6c3:468c:6caa with SMTP id bq15-20020a056a000e0f00b006c3468c6caamr100762pfb.6.1700765316510; Thu, 23 Nov 2023 10:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700765316; cv=none; d=google.com; s=arc-20160816; b=NMrVUwVPtj1bx8Lj1Q0G7hD3E3oSLtG11MLcPP2uQWP/vNRw4L09MLpnUk5uevaxHd DjxA5JXmu04Rncrqik0xv5saT7mBKmGNQ0+lKYKdhWRavP2F+KZN1pkcfPT+O7TliEyn mra2Nhj60cazgVUhap9H7P0hthX4Ch3Zg6rMgXJ2IWHlEfUXyu4frpMTR0ivvBG3/uSc z+5YTGSCC0c9cGhukuKNHcy/olfnPKCNTpkkn1/hZbfd6J29OZdSAgptT9gP55Kc8UH9 vsYI40Q5bjtvmqAlJ3coergoOWSdddDrX2W91UBCVbSPlfXmDuMdiPevx2K99qmCbvha wMRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=l1r9JxSmLJtBWwQD5WMXoyMpcIa8PCU8/HG8nOTjmTc=; fh=NSvAzB9689xOzGb9utbYfCotqde6p2+uodY2iw9anZY=; b=vu5KNcoRmcSkBaSxFwwEAJbAPfUUnnAtYNNeZMNnHUbbIlhlU1TIkDfZkPQOw9Po8E gd8KAwVq/x0XuvoJUXZEPNoYWmGB5l0D1hMRi/betibEXAFT1nWmuuZUs7IQSIm6+EIx RaoSkJ1ao12riJj7A3Vbyu3HE44ZJUnEp05zTenG835SgrTn9B+2PxzIfXxYYRasg1TJ Z6dIjlYnYNNRigGs/F5cZEjXpbtlWBjxtfCPa9J/yJNGAGpJFQWRrRCJ96GuXGVDv3x+ FevVcWaQMB1cHnxO1KFBV7OxG3+zI6dy/Z4gQoQSNfEPj3QwrKbluqtv9CBWvT6kFgvL OLhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JDW6Buyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id v1-20020aa799c1000000b006cbef428d23si828425pfi.326.2023.11.23.10.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 10:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JDW6Buyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4CEC08060C82; Thu, 23 Nov 2023 10:48:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjKWSsN (ORCPT + 99 others); Thu, 23 Nov 2023 13:48:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjKWSsM (ORCPT ); Thu, 23 Nov 2023 13:48:12 -0500 Received: from mail-vk1-xa2e.google.com (mail-vk1-xa2e.google.com [IPv6:2607:f8b0:4864:20::a2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E1419D for ; Thu, 23 Nov 2023 10:48:18 -0800 (PST) Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-4ac211e5bbbso1246835e0c.1 for ; Thu, 23 Nov 2023 10:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700765298; x=1701370098; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l1r9JxSmLJtBWwQD5WMXoyMpcIa8PCU8/HG8nOTjmTc=; b=JDW6BuyjNYMldZAJl+8zbnStBDU7IVrrh+45xGV2YB8Mc8WgGAjrBhtx7c/bvH3uE0 GXdkJmrfckerymqAxpp19rkehnTX9HBBlSaJgzCq5Hb5hxVxO/vASuRkegpqdQa4T6Qn yh/49mHNEmITi621N0Caog8SDRsa6DPJrvs6CTPb9qHycLE66IXxNXHqxXFjIPHQ/PPy 6DHA9m6olsQQhuPyMvilBksq/Rj+fxqcMCd0R+lOupVDw3q+FjqSc/tBCkMqz8jyijCm fP6cCDrTP7O9I5tFuvAB3c5HypD/TuTsKt5m3rQC39VN3O848mOvCagPxCfERHLBN/hi 9Bxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700765298; x=1701370098; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l1r9JxSmLJtBWwQD5WMXoyMpcIa8PCU8/HG8nOTjmTc=; b=NbPZCkPMXPoghvHMMQQehuWWtIyw0XtkOu4xbFDsC7kKlEkjHaTgbyvSDENGE0csxB pnayOUOdF3LN+qJzd0zYzPfNzN4oJk2CGxUAA4U1lLQXmTJINayEcbk/sthQgDpnik0Q Y5T74DdFi+U6KQXIuaY9YsRq7ffC5Znhdn14SGqIGTN4mV4Md9Rnaw6cFF1RRhK8gDAE ks5qjCVxpMDDZeFEtPL+QepWlfnOW9rVm+9jsKpeUNg8dPsjHi3nDeIO+fHcQdDt/FgT mXd9df1T22CyvCHEVvzLjcGYttbD+crKgc/cdKW5jthRNePzeUkTw1J8NI6DxQz73X9z 3ZKg== X-Gm-Message-State: AOJu0YxnW8j3yy8zQmBphfKclyEm5OkTNgLul6kjb7NX7mDZDn89CDha 3DV9vsZfNp6j6F5kruI0VGS4u0LM2Tnzb5QH/xe7bg== X-Received: by 2002:a05:6102:38c7:b0:457:c953:bc39 with SMTP id k7-20020a05610238c700b00457c953bc39mr3960679vst.1.1700765297816; Thu, 23 Nov 2023 10:48:17 -0800 (PST) MIME-Version: 1.0 References: <9752c5fc4763e7533a44a7c9368f056c47b52f34.1699297309.git.andreyknvl@google.com> In-Reply-To: From: Marco Elver Date: Thu, 23 Nov 2023 19:47:40 +0100 Message-ID: Subject: Re: [PATCH RFC 14/20] mempool: introduce mempool_use_prealloc_only To: Andrey Konovalov Cc: andrey.konovalov@linux.dev, Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 10:48:33 -0800 (PST) On Thu, 23 Nov 2023 at 19:06, Andrey Konovalov wrote= : > > On Wed, Nov 22, 2023 at 6:21=E2=80=AFPM Marco Elver wr= ote: > > > > On Mon, Nov 06, 2023 at 09:10PM +0100, andrey.konovalov@linux.dev wrote= : > > > From: Andrey Konovalov > > > > > > Introduce a new mempool_use_prealloc_only API that tells the mempool = to > > > only use the elements preallocated during the mempool's creation and = to > > > not attempt allocating new ones. > > > > > > This API is required to test the KASAN poisoning/unpoisoning functina= lity > > > in KASAN tests, but it might be also useful on its own. > > > > > > Signed-off-by: Andrey Konovalov > > > --- > > > include/linux/mempool.h | 2 ++ > > > mm/mempool.c | 27 ++++++++++++++++++++++++--- > > > 2 files changed, 26 insertions(+), 3 deletions(-) > > > > > > diff --git a/include/linux/mempool.h b/include/linux/mempool.h > > > index 4aae6c06c5f2..822adf1e7567 100644 > > > --- a/include/linux/mempool.h > > > +++ b/include/linux/mempool.h > > > @@ -18,6 +18,7 @@ typedef struct mempool_s { > > > int min_nr; /* nr of elements at *elements */ > > > int curr_nr; /* Current nr of elements at *elements = */ > > > void **elements; > > > + bool use_prealloc_only; /* Use only preallocated elements */ > > > > This increases the struct size from 56 to 64 bytes (64 bit arch). > > mempool_t is embedded in lots of other larger structs, and this may > > result in some unwanted bloat. > > > > Is there a way to achieve the same thing without adding a new bool to > > the mempool struct? > > We could split out the part of mempool_alloc that uses preallocated > elements without what waiting part and expose it in another API > function named something like mempool_alloc_preallocated. Would that > be better? Yes, that might be better. As long as other users of mempool (esp if KASAN is disabled) are unaffected then it should be fine.