Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2311383pxb; Fri, 25 Mar 2022 15:12:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxuLENOdrTEtg28KP7W+1HMFNS6feeJpqS7K3myY89pCAyqqq/t+xenXcbI2Jn7WLzppcr X-Received: by 2002:a17:902:7888:b0:148:adf2:9725 with SMTP id q8-20020a170902788800b00148adf29725mr13832672pll.136.1648246378119; Fri, 25 Mar 2022 15:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648246378; cv=none; d=google.com; s=arc-20160816; b=KO83k43mSBZpd5KEc1tzQNFd+x/O+uhjKTzcVfKyM+itxRWpwPUiE1yK/YFcsQLN5D lSaY0NXQGhPyT+23W/djiTKuLKXzcjk56ELl1ZHTjlPqCDRhaX+ZVWnzs33ek84Ak6DE pgrg+FGeXji61WYkH0XW/0+5PV949nr7RCVYwDkZXh9iPRTTubZLyr7ZZGKkmccDL4BX Pu+xJ0HvyXw9iM+ZYYcHjtmKtX0n/Lk+Z6bYmMcV6UiBjQ/t4zviL7O/A7ZP+Qevx5/u AGJWjotvXr8MkNkA6UB36cWC0IQjNunpf+W99EBngZvBnimODLfAcP0hdxhMT/7yPe5t xcRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Rel2cA69nxFMycnAlTbLC9e3jy4Z5HkvrU+j7Z2Tobc=; b=aBnNXwLkPkONsjmH7JeegqFh5mYBG6C8MX22q6BBBOmmUOHPZpMe+X48QCO1gRN/6q lhFFteWuuhwasnxhOdmjKXMXkA4Ij8XQQKizPVQ6KZQn5KVnhhJU3WwfsYTSmYdA1nTz P6YMLccH1JwHkz1moTLwX9iX7247u8U19GIwRrJeIAY9thpWSQogRBEcMHzN7KeDdUyE ng9QysfHKNYyHS4xnV64rjQELTRYVA7MDlhsf8tGnRdNurpPAtf+Rmwx6T8Sma23551J o6WsxzDeWg9nnZ5nH9jKqtz4oq+B23ltIasi+gj1f6N9PohG4H4MHrzCM2kuInOy203r QEPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lOelYMRO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h10-20020a63574a000000b0038288abe5f7si3383280pgm.230.2022.03.25.15.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 15:12:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lOelYMRO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC2C29D0FC; Fri, 25 Mar 2022 14:48:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233551AbiCYVtf (ORCPT + 99 others); Fri, 25 Mar 2022 17:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233526AbiCYVte (ORCPT ); Fri, 25 Mar 2022 17:49:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8402072E2B for ; Fri, 25 Mar 2022 14:47:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 442D4B829BA for ; Fri, 25 Mar 2022 21:47:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97DDEC2BBE4; Fri, 25 Mar 2022 21:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648244876; bh=h69lJXxPvdDbpf3yxkrVDt5yfQsu4aPDbdi8wU3rEIU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lOelYMROko3tudh2p6g2zXIfc3GhY2JxOsoAHFD8KYilnjCUi5JZ5NuUVN6j6VbIJ 3BlqYOxuKldnpTzj0zjZd7uzoloHcI9DmdiMmXU/u8CaCP7W3O38Jl88v7bEonpFjY N+XJo9SLXcdlTQnpi4s2Irp/kkdbr7PTJ6+014BE= Date: Fri, 25 Mar 2022 14:47:55 -0700 From: Andrew Morton To: xkernel.wang@foxmail.com Cc: glider@google.com, andreyknvl@gmail.com, elver@google.com, dvyukov@google.com, ryabinin.a.a@gmail.com, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/test_meminit: optimize do_kmem_cache_rcu_persistent() test Message-Id: <20220325144755.c0a92c6fd934b4cb98c41c16@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 Wed, 23 Mar 2022 11:48:24 +0800 xkernel.wang@foxmail.com wrote: > From: Xiaoke Wang > > To make the test more robust, there are the following changes: > 1. add a check for the return value of kmem_cache_alloc(). > 2. properly release the object `buf` on several error paths. > 3. release the objects of `used_objects` if we never hit `saved_ptr`. > 4. destroy the created cache by default. > > ... > > --- a/lib/test_meminit.c > +++ b/lib/test_meminit.c > @@ -300,13 +300,18 @@ static int __init do_kmem_cache_rcu_persistent(int size, int *total_failures) > c = kmem_cache_create("test_cache", size, size, SLAB_TYPESAFE_BY_RCU, > NULL); > buf = kmem_cache_alloc(c, GFP_KERNEL); > + if (!buf) > + goto out; OK, Normally we don't bother checking allocation success in __init code, but this test can run via modprobe, so I guess checking is the right thing to do.