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 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D00A4C43331 for ; Thu, 7 Nov 2019 21:19:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7298D2077C for ; Thu, 7 Nov 2019 21:19:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L7v0SvPM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7298D2077C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EB1666B0003; Thu, 7 Nov 2019 16:19:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E132D6B0006; Thu, 7 Nov 2019 16:19:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2A796B0007; Thu, 7 Nov 2019 16:19:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id BE1126B0003 for ; Thu, 7 Nov 2019 16:19:54 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 64999181AEF1D for ; Thu, 7 Nov 2019 21:19:54 +0000 (UTC) X-FDA: 76130748708.05.iron53_566b410488c49 X-HE-Tag: iron53_566b410488c49 X-Filterd-Recvd-Size: 5035 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 21:19:53 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id q26so3311838pfn.11 for ; Thu, 07 Nov 2019 13:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=viAE1CpzSxuRD/BH/MsOEcY+j2yNDU+1S4harELGxYA=; b=L7v0SvPM5wqtmIimdjoJlflFSCiarLVuMjw5tUDVJV49TBb/GIt3CUBOIRdHA3BebG Ve5aORzfLA3uMKYoSVZ1gtyANrv2YIhfT/YcS6c3Q8pkkKaEMXiPnQ6k95ZHy7YBdqKu wHLJLsaK2CXPSDDGzOxGxu8cIP/NX7P3BJYgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=viAE1CpzSxuRD/BH/MsOEcY+j2yNDU+1S4harELGxYA=; b=H1/LZx59ovtFSrGFd33dYG679mb8jlVj4ch5cxHQCNAMMFbXSQPPjfP6IXWu6wsgd4 QjPcbe2qxakqpHAfNqqK/5QZ9mrM9vAfszt3Tp6WhRRm7LlJuJ8q21+kQUjjKuZq9Ho+ H0ZTDZDmDcgk0F+qwt8cds1VJrvKVvux7xsP6PFBnDLXyigS82MziO9O5+rYDl6/tjIz iKMMf+bw2IJv13twIMX2CVTOdk+hNkakT8WzXDx2+HTaf/C9f5Ct5AsIGEtzhED+gkwn T5fv+1D0sgS5K3Mc2jbIC8E/ifnf17ltuunkGXtvp703k68Pk7V0urYPe8QnlZFDiRzT xncw== X-Gm-Message-State: APjAAAX9KJt11fygEPfJHxWdMH9daNbYApiA94+OZYmwPMJBEczv9waA EjIeISe6Dxi0TKf/yu/+Qp2qTw== X-Google-Smtp-Source: APXvYqyO2euuNiOHUndxT0zs1UCgY+o45HB5aAKJRIOZnSb6erehLpmH4sarPYmnZvA+5tGzW5rT/w== X-Received: by 2002:a63:5c21:: with SMTP id q33mr7533017pgb.61.1573161592677; Thu, 07 Nov 2019 13:19:52 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id r13sm3040014pgh.37.2019.11.07.13.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:19:51 -0800 (PST) Date: Thu, 7 Nov 2019 13:19:50 -0800 From: Kees Cook To: Laura Abbott Cc: Alexander Potapenko , Christoph Lameter , Nick Desaulniers , Kostya Serebryany , Dmitry Vyukov , Sandeep Patil , Jann Horn , Marco Elver , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH] lib/test_meminit.c: Add bulk alloc/free tests Message-ID: <201911071318.A2FB7A9@keescook> References: <20191107191447.23058-1-labbott@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191107191447.23058-1-labbott@redhat.com> 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 Thu, Nov 07, 2019 at 02:14:47PM -0500, Laura Abbott wrote: > > kmem_cache_alloc_bulk/kmem_cache_free_bulk are used to > make multiple allocations of the same size to avoid the > overhead of multiple kmalloc/kfree calls. Extend the kmem_cache > tests to make some calls to these APIs. > > Signed-off-by: Laura Abbott Thanks! Andrew, can you add this to -mm please? Reviewed-by: Kees Cook -Kees > --- > lib/test_meminit.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/lib/test_meminit.c b/lib/test_meminit.c > index 9729f271d150..20f330948b92 100644 > --- a/lib/test_meminit.c > +++ b/lib/test_meminit.c > @@ -183,6 +183,9 @@ static bool __init check_buf(void *buf, int size, bool want_ctor, > return fail; > } > > +#define BULK_SIZE 100 > +static void *bulk_array[BULK_SIZE]; > + > /* > * Test kmem_cache with given parameters: > * want_ctor - use a constructor; > @@ -203,9 +206,24 @@ static int __init do_kmem_cache_size(size_t size, bool want_ctor, > want_rcu ? SLAB_TYPESAFE_BY_RCU : 0, > want_ctor ? test_ctor : NULL); > for (iter = 0; iter < 10; iter++) { > + /* Do a test of bulk allocations */ > + if (!want_rcu && !want_ctor) { > + int ret; > + > + ret = kmem_cache_alloc_bulk(c, alloc_mask, BULK_SIZE, bulk_array); > + if (!ret) { > + fail = true; > + } else { > + int i; > + for (i = 0; i < ret; i++) > + fail |= check_buf(bulk_array[i], size, want_ctor, want_rcu, want_zero); > + kmem_cache_free_bulk(c, ret, bulk_array); > + } > + } > + > buf = kmem_cache_alloc(c, alloc_mask); > /* Check that buf is zeroed, if it must be. */ > - fail = check_buf(buf, size, want_ctor, want_rcu, want_zero); > + fail |= check_buf(buf, size, want_ctor, want_rcu, want_zero); > fill_with_garbage_skip(buf, size, want_ctor ? CTOR_BYTES : 0); > > if (!want_rcu) { > -- > 2.21.0 > -- Kees Cook