Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp519577rdh; Thu, 23 Nov 2023 10:07:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0bCfZECQ/4zPOngyyaIBsTCVcYosMLBUlgyozOty1PdtRzj0qFEQ38+2rCXVNqZLE8vzq X-Received: by 2002:a17:902:e806:b0:1cf:6768:59fd with SMTP id u6-20020a170902e80600b001cf676859fdmr283172plg.59.1700762851476; Thu, 23 Nov 2023 10:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700762851; cv=none; d=google.com; s=arc-20160816; b=iz1Vnz7vLZ4+ekIKsFMjxlnfmA7ZH1eYT9JK0lmxejHcARvwXdXMqVNV36utrXvCcf Fsz16GEoPAOgB5javh4RQq2yzAM6ePyWITEazeVtYHtzemAXtdSLe2EDc58Tn8nqAerC Z9tqrEWbHmbnVR9Yc5NnQxZxOqKw7Gi6DWrpJgyKExjLub0gf+yK//d/4yvw+pLXxYzv JgO8kFUQblcHtbJ3ggjC/o/5CHqZ9yAfTaztFGTCdWD7fxDHLWdciD1WHj0jd6OZgE65 +WsUUCp0+ckYuvTntj29E/TgTpMd4YPHx75fH7FPTN/M04Uq1+8O0Xn7nVqMcvl0mSzM cqkQ== 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=HOe1NePRnmjI5/xj2NE8BgAqPHEuVYA8qvj9b+OSxE4=; fh=YkVDR0A+vozh5A2Ys2bfc3KlovOzAXgaZ4cuYbKRmSk=; b=Ug3XHrYqpydPOHiLX+FmyOtCyvftOP1x+yMTjLdlscOB6INBUPLR9rzvDg74r6ixo2 AFQMpuXqKiEhPdCP6v356mf+03W4sea2Ip0FydU26ZgcfNqeEkiYR7H72Rnpn1Gzj5jK TyCX9ZGKRY2hmdymohzcnKknA/pp7p42swzdPlYgmjcn+Ib4t335+NY2ybX/TtqS/Lql Z7sqPD1z1vBMKOF19WLU4OQSTnZ3lVzHO5ZQdW92eNaPtI6QyfdoWkD01/E7VO/tkzzG zHGDsEBXkQCHm3BAzLHxVpyUxpaRjyCMWoNlJquDoVNRxFGg6qXLBRyM8wliwQeCCOoG aLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QvwX3O6G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y7-20020a1709029b8700b001c7342b46e4si1544227plp.23.2023.11.23.10.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 10:07:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QvwX3O6G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3C3B88227433; Thu, 23 Nov 2023 10:06:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbjKWSGX (ORCPT + 99 others); Thu, 23 Nov 2023 13:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjKWSGV (ORCPT ); Thu, 23 Nov 2023 13:06:21 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ADFCD5E for ; Thu, 23 Nov 2023 10:06:28 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c1f8b0c149so743320a12.3 for ; Thu, 23 Nov 2023 10:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700762788; x=1701367588; 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=HOe1NePRnmjI5/xj2NE8BgAqPHEuVYA8qvj9b+OSxE4=; b=QvwX3O6GO/POlaq+PTSspRHagA1Qq80kfpBEEgyGrBiJqhp876TuaP1tcIwex4I73w RjTTkei6mNrD9fw7KZtlMaZCzQ0XiFC9tG68rJE/93kEkhl7AgGIjc0yDyENQimMmHHH QIVBoMAUwGcSEZnQGQPu5dbkYHevljKAD8SOv8XrUfrK32Ix4Jy7BjP8a6Wrp+8xdX5T e7OA4hbKUnrXVJWeuAB1c6vxk41V/a8e3AG9RJJu0BDddi02lJKwxQ/37nu0ehkSD0/V XaaV+M8JOWnJGwQUjadTTS9wWnG4aNK+Vt+lwNH847MJhw96FMI10qbn6mgZB7ZPPRB2 uXcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700762788; x=1701367588; 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=HOe1NePRnmjI5/xj2NE8BgAqPHEuVYA8qvj9b+OSxE4=; b=oNSzM2zg1aJmTuh1mEzegRi8N8lAdbJRrgBMPWp86Vpec9XXfBURyoaCOIPsit9eMt agSrPtpVnQKUVpmFE5HO22bdOAJWUYs3X7I9RHiVkjxIdJw3kwmey14oKV9/E0dTleyx KAYcqy+GIIHh7PyRK3wBjmbznpwyifqpwDONlgq/5WJHN+1u/vOAF1RZk2Y++27FtmTw yOAe9fVWJ8joG3/LAtQCe9uWZNow7zSK2blvGn/ZQxVwOiXWaYLcs81CIj2+yYWMRFQm 6AU5Lf+bzXZFl4L9tIbu7R55S2frw3I1Rqbq0RUyLirScucd2ZbRQ6GY+7ri1Mh06sBx 9rNQ== X-Gm-Message-State: AOJu0YxWuUbCNGbcEXXYbLG/Rzw7BkuLYXKjqRYu2f+WFW/Fm1XADWam m0rfXdsFQOK0eVMtnFlsckrhvgQA/fLeEbrj4Sw= X-Received: by 2002:a17:90b:3a8d:b0:280:1a19:6dd5 with SMTP id om13-20020a17090b3a8d00b002801a196dd5mr162675pjb.36.1700762787678; Thu, 23 Nov 2023 10:06:27 -0800 (PST) MIME-Version: 1.0 References: <9752c5fc4763e7533a44a7c9368f056c47b52f34.1699297309.git.andreyknvl@google.com> In-Reply-To: From: Andrey Konovalov Date: Thu, 23 Nov 2023 19:06:16 +0100 Message-ID: Subject: Re: [PATCH RFC 14/20] mempool: introduce mempool_use_prealloc_only To: Marco Elver 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=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 10:06:38 -0800 (PST) On Wed, Nov 22, 2023 at 6:21=E2=80=AFPM Marco Elver wrot= e: > > 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 functinali= ty > > 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?