Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4925265iob; Mon, 9 May 2022 05:02:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWEb0KUelBQLQdR9XrCBrLRgONVrZwTPo9bPhhlfg0hc7i3yBwjdBfzb33mgP6aXlV/G/U X-Received: by 2002:a65:6e0d:0:b0:3c6:12af:15b4 with SMTP id bd13-20020a656e0d000000b003c612af15b4mr13030113pgb.338.1652097726489; Mon, 09 May 2022 05:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652097726; cv=none; d=google.com; s=arc-20160816; b=FHb0uCGwHI3N+FY0aF5WoCp8bRCc8d+hpjKxeGfLcIMhqKw5sGYBNZDzSm7mj58MvT yX7oKR2kvpG1APN6ykSHY4+kJVSZOLCiH6siXzWPYGK+MMqv/n5y8DCRxNLR80h9gh0r XRXnaoq4oEwBRKlot6dEvptjRuFY1HD+xqWSRBnsqbrcRNS3BgrQ7k1/Ak+mngHmQhPU KQgXkpWQE6cOZd0B2PuK7UBtWMBsaOKl9Cmgu6F/B2lrKWUFeh1BzefPAGIyXMGqow6v t+eC9kV+kmPANrF5p18Nj4ypOhcqPXYo8MNRoorbH4NPUVPiIreOkuNF92AAf8kjgMOZ lJxQ== 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=MPgbgqFyUzi/pFIIl7e5TfJ4g1kI/3PaA6Fy/1JOhfo=; b=gh1gdw3UwcrkaBEpZFJh6cEy175sX5wmjIAppE7+vlH1jPnsx7kSWw14FxHU7H1+d6 lj2mYvZ6FIixwRcWSPJWgEjOgYdYZy+MSn5J8vsE40xo4KIQ9GHvm5vI61tQRse3udfl e46PO4FUpj+94RCAL4ehpSSVO6wzsZdnN+Bgywh2pKQtrDur7fapGqH6rRiY/o2yXGO0 ViuiLwfhoYyZuHWvFrWInw1wZ4URSHg6h6dGKtE+VIPoYuXwsDv25AgpnF/RXSWXK2mr tsAIoeP3qLJw+gtz06rDw3TY6GrOpYazjEt5dv7xTHVcujkES5u+M6K/kWlBuZtDERN/ pG2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LXyc68wE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i12-20020a633c4c000000b003aaf01e9decsi15191251pgn.104.2022.05.09.05.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 05:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LXyc68wE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04C4B1CA040; Mon, 9 May 2022 04:21:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbiEILZD (ORCPT + 99 others); Mon, 9 May 2022 07:25:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232306AbiEILZA (ORCPT ); Mon, 9 May 2022 07:25:00 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E427F275D2; Mon, 9 May 2022 04:21:05 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so2011745pjq.2; Mon, 09 May 2022 04:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MPgbgqFyUzi/pFIIl7e5TfJ4g1kI/3PaA6Fy/1JOhfo=; b=LXyc68wE9Tqryc7MXDlYdhdIOKehEozgCEtEPNYYV8YYudUQtKzmgy5hfOIVQTJ9sC KrVakukKljSFGzfObUSuFnO9vFYU3rhBEVlBBzbfH2RSA7bV5GZYYuuoF00hIQjMrdHk 8v6Vw2rB4VyXQHMdcfBibLStLlTFqHQOy2xLDWTHyEQZ7iiyoLHWKcA7PKqed5DALb0h QQcms6zuYXy9k9CQ9hCvLfjRc0r1hHy6NPBgnzGNfzV01x2j/kIDBkGKhX2TMEKsddOv kjkRI3D0K1cInlxHRfZVFCs0CA2nifvB5lacSVDUgBCSF6YndZh3xspcW7JNa8hcx3Uj YLtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MPgbgqFyUzi/pFIIl7e5TfJ4g1kI/3PaA6Fy/1JOhfo=; b=ZVIZF0M+kzp+JuuzK5TwL7/SmysClj5kugysySzM/GLI7dTu5kaa5PhyvEGJA37aR0 MGPjO1PtmHJ89PG2yKZ73xJKLwN8cbbv/rLWuSSCaLpPPdZSNm+oJJRNvav7hHNuUWk4 +LNupWOSnTKZx15C6orxzJH8rDcT4Hi/7M5melQDAE27nsOTsJxXU2dZevbNmnetycXk SKS0/aBPJBg+xCDPK+XcCALLb9gjqjkpObAw2vU8aXFAGAaJlAk/wEBZ8DI3tYRXC/9W PZwY3WOEOIsB98TR4+KtKzcHFmcpseNm4Qr/BF6WO534lXCwelaykfFGNttoDKB/nX8v 1tLw== X-Gm-Message-State: AOAM530h8K8DXdUojUL0YPV5JTbpr0sW/+C2nZXjJoJulOYAflKfXaeO 6PwsguoSjnaLbJhVhfypN/s= X-Received: by 2002:a17:90a:884:b0:1d9:531c:9cd6 with SMTP id v4-20020a17090a088400b001d9531c9cd6mr17211836pjc.211.1652095265364; Mon, 09 May 2022 04:21:05 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id h13-20020a056a00000d00b0050dc7628173sm8461311pfk.77.2022.05.09.04.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:21:04 -0700 (PDT) Date: Mon, 9 May 2022 20:20:57 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Paran Lee Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , linux-kernel@vger.kernel.org, linux-mm@vger.kernel.org, Oliver Glitta , Austin Kim Subject: Re: [PATCH] slub: kunit catch kmem_cache_alloc failed Message-ID: References: <20220506045319.GA28237@DESKTOP-NK4TH6S.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220506045319.GA28237@DESKTOP-NK4TH6S.localdomain> X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, May 06, 2022 at 01:53:19PM +0900, Paran Lee wrote: > Catch kmem_cache_alloc failed on slub kunit test. > > Signed-off-by: Paran Lee > --- > lib/slub_kunit.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c > index 8662dc6cb509..7b80241dd498 100644 > --- a/lib/slub_kunit.c > +++ b/lib/slub_kunit.c > @@ -32,6 +32,11 @@ static void test_next_pointer(struct kunit *test) > struct kmem_cache *s = kmem_cache_create("TestSlub_next_ptr_free", 64, 0, > SLAB_POISON, NULL); > u8 *p = kmem_cache_alloc(s, GFP_KERNEL); > + if (!p) { > + kunit_err(test, "Allocation failed: %s\n", __func__); > + kmem_cache_destroy(s); > + return; > + } > unsigned long tmp; > unsigned long *ptr_addr; > > @@ -77,6 +82,11 @@ static void test_first_word(struct kunit *test) > struct kmem_cache *s = kmem_cache_create("TestSlub_1th_word_free", 64, 0, > SLAB_POISON, NULL); Recently SLAB_NO_USER_FLAGS is added for test caches. Looks like it's not based on Vlastimil's slab tree: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git > u8 *p = kmem_cache_alloc(s, GFP_KERNEL); > + if (!p) { > + kunit_err(test, "Allocation failed: %s\n", __func__); > + kmem_cache_destroy(s); > + return; > + } > > kmem_cache_free(s, p); > *p = 0x78; > @@ -92,6 +102,11 @@ static void test_clobber_50th_byte(struct kunit *test) > struct kmem_cache *s = kmem_cache_create("TestSlub_50th_word_free", 64, 0, > SLAB_POISON, NULL); > u8 *p = kmem_cache_alloc(s, GFP_KERNEL); > + if (!p) { > + kunit_err(test, "Allocation failed: %s\n", __func__); > + kmem_cache_destroy(s); > + return; > + } > > kmem_cache_free(s, p); > p[50] = 0x9a; > @@ -108,6 +123,11 @@ static void test_clobber_redzone_free(struct kunit *test) > struct kmem_cache *s = kmem_cache_create("TestSlub_RZ_free", 64, 0, > SLAB_RED_ZONE, NULL); > u8 *p = kmem_cache_alloc(s, GFP_KERNEL); > + if (!p) { > + kunit_err(test, "Allocation failed: %s\n", __func__); > + kmem_cache_destroy(s); > + return; > + } > > kasan_disable_current(); > kmem_cache_free(s, p); > -- > 2.25.1 > To be more paranoid kmem_cache_create() can also fail - but I'm not sure these checks are useful for tests. -- Thanks, Hyeonggon