Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp893076iol; Sat, 11 Jun 2022 23:41:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv9lb8b444G6GCFDiwsjiwCDEhCMxJ12YIDw5dlfrh1ItplW8p2hqBpJi8bQyQCMyQz1a2 X-Received: by 2002:a17:902:e80d:b0:167:5e77:e695 with SMTP id u13-20020a170902e80d00b001675e77e695mr41698239plg.144.1655016084729; Sat, 11 Jun 2022 23:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655016084; cv=none; d=google.com; s=arc-20160816; b=yFMKWIyibN85Zbu41gSYlwUZz7hgkW3F9M1j0ZL1iiBODr0CopGtjlZDmLehOX/WMr HduPsGMK2rHNnrdWbqMIdTaRLmZVHR4h3hzfNZRJLL8DIn7nnpa2n/0857cGWjLK9hL9 lsSte7wfTbBtRDeY5z1S5DXQiMwCNfg9HmFnqBurVgJUJLAAMhtgUmYrQ4cZhlFKateJ HG40C3p2LUSsJ0V3ttbVxnAhhuqsgIlaI3S1u2kIum6ojMCU4w0PCP02uJmoYosRO0yG aiEVE2Le0Wthu/iw7K7zF8Vmx9CvXXHOuSJWH37oJs9CSh/e5YIqUfjHrD8FW7zLVgaP 8kpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qiT1iJby4LsQAwA4+dfYrsd6yIz4GeMBtxNAoo+lcQE=; b=iNWphTNLatG5ch/m5PDw2hMBo9+bEPnfjOHEHpOViNE+X3Ud3CJW8BoYLlQai1J0PJ rOIxY5ak7ngUHbaU69p3nF9SM751+1zmhV5q00nu2XwBZs6zjUtrkOiRLMGOZmiqkFwT d7m9wCnJ6BZO86zuqCs5jotziOstpR+SDRJml8KTcYXeQkRAzTuGhEo3PzXW09xjDIzh QuxsvPbPiu4msOHR73zIWCBl+ia+4If1kzcDwBjrjTcmsS19yPRyqe/KwqDhT4vfK8hf 0EuT5MxfU0Si8MhL/kSON93z344gsEKeK5FoAwytMgkzQCwLhnLdnblrpoql36jl4oDs VJpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a056a00191600b005108b38be1csi6092154pfi.80.2022.06.11.23.41.03; Sat, 11 Jun 2022 23:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234483AbiFLGLQ (ORCPT + 99 others); Sun, 12 Jun 2022 02:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiFLGLP (ORCPT ); Sun, 12 Jun 2022 02:11:15 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90ADC5F67; Sat, 11 Jun 2022 23:11:13 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id C69121E80D78; Sun, 12 Jun 2022 14:10:11 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cuOdn4AlAeKG; Sun, 12 Jun 2022 14:10:09 +0800 (CST) Received: from [172.30.21.244] (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 7F34B1E80C8B; Sun, 12 Jun 2022 14:10:08 +0800 (CST) Subject: Re: [PATCH] rcu: Handle failure of memory allocation functions To: paulmck@kernel.org Cc: Davidlohr Bueso , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, hukun@nfschina.com, qixu@nfschina.com, yuzhe@nfschina.com, renyu@nfschina.com References: <20220611093055.1473-1-liqiong@nfschina.com> <20220611163432.GM1790663@paulmck-ThinkPad-P17-Gen-1> From: liqiong Message-ID: Date: Sun, 12 Jun 2022 14:11:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20220611163432.GM1790663@paulmck-ThinkPad-P17-Gen-1> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 在 2022年06月12日 00:34, Paul E. McKenney 写道: > On Sat, Jun 11, 2022 at 05:30:55PM +0800, Li Qiong wrote: >> Add warning when these functions (eg:kmalloc,vmalloc) fail, handle the >> failure. >> >> Signed-off-by: Li Qiong > Good catch, thank you! However... > >> --- >> kernel/rcu/rcutorture.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c >> index 7120165a9342..97f90e304ae3 100644 >> --- a/kernel/rcu/rcutorture.c >> +++ b/kernel/rcu/rcutorture.c >> @@ -1991,6 +1991,10 @@ static void rcu_torture_mem_dump_obj(void) >> >> kcp = kmem_cache_create("rcuscale", 136, 8, SLAB_STORE_USER, NULL); > As long as we are checking, why not also check this one? > > Thanx, Paul Hi Paul, Yes, the kmem_cache_create would fail too. I searched "kernel" directory, found that It seems all the code just check kmem_cache_alloc(), So, I ignored kmem_cache_create() . I will submit a v2 patch. Thanks, Li Qiong > >> rhp = kmem_cache_alloc(kcp, GFP_KERNEL); >> + if (WARN_ON_ONCE(!rhp)) { >> + kmem_cache_destroy(kcp); >> + return; >> + } >> pr_alert("mem_dump_obj() slab test: rcu_torture_stats = %px, &rhp = %px, rhp = %px, &z = %px\n", stats_task, &rhp, rhp, &z); >> pr_alert("mem_dump_obj(ZERO_SIZE_PTR):"); >> mem_dump_obj(ZERO_SIZE_PTR); >> @@ -2007,6 +2011,8 @@ static void rcu_torture_mem_dump_obj(void) >> kmem_cache_free(kcp, rhp); >> kmem_cache_destroy(kcp); >> rhp = kmalloc(sizeof(*rhp), GFP_KERNEL); >> + if (WARN_ON_ONCE(!rhp)) >> + return; >> pr_alert("mem_dump_obj() kmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp); >> pr_alert("mem_dump_obj(kmalloc %px):", rhp); >> mem_dump_obj(rhp); >> @@ -2014,6 +2020,8 @@ static void rcu_torture_mem_dump_obj(void) >> mem_dump_obj(&rhp->func); >> kfree(rhp); >> rhp = vmalloc(4096); >> + if (WARN_ON_ONCE(!rhp)) >> + return; >> pr_alert("mem_dump_obj() vmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp); >> pr_alert("mem_dump_obj(vmalloc %px):", rhp); >> mem_dump_obj(rhp); >> -- >> 2.11.0 >>