Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp224343iol; Sat, 11 Jun 2022 02:44:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1nQf56zfpG7tNsCe8OwFPDYxSMJR+iC7M6yRNc9B3Wo8wVk7AzG1ZJdjjD5cYFgAJ6VAo X-Received: by 2002:a17:903:22cb:b0:167:992f:60c4 with SMTP id y11-20020a17090322cb00b00167992f60c4mr22055934plg.22.1654940646920; Sat, 11 Jun 2022 02:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654940646; cv=none; d=google.com; s=arc-20160816; b=Dux9WCkdSeUPfKOcwkqromUDnsxn8xxU7mHa26oIaKDCcHQEZvYTVhx3zPINtZpD9m 7I3R2TYT6bnXXUFayYtOyOSyAA/Pi50NWg6C0QglxXFJnmMSaxiLeiaUddFn5ZaSsqoi XeQNp0RoyhNwVqx7oOTjPSbkz5GjuZuba502UxeNUq4PcyBe6b2VK5CXqu5BdYeL8J3T 8GakaYFf42h/n/4v72QKaRO8KMYMESjKSawVH5EsSQiqmV11328XoKkA/kf8GxaTH9Jz ykxYs3QbzsNsH2ESk0WODL3QO10oGvoGYMBMGIQo43DvyVXATRQlKi9Qngjt6jw2Ocix JdSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=C/+xeZy88gSxZrcjbGwgZTQKR643Ix6g4VxdkTFdLBM=; b=HAsFXPl9lrsTTVhszhlIHoyr9AvwyrePWHCfL9SWLzRxHwCRxoT0sNK4OwSg8QCURB QVYR6ZwmujAvqgVfXsQlVLmI30gJjlfsSenqua949bFgELBtgUGQcRCfk2GNTbXDR8oT hIf8caPBv2MRkWHVOPL650DGxc0tzxrqt9944Ju6VPZhRd1G0keF0TAfnGFwtmDoBEqD J0V6E7/KJn/MpGJ2TXnwhy47VpvUrTZ+AbL4IOYvBqly4L905yvSiNYj2caNoUsjD/gk VgspVlgxgwxWiQ9u269ZqMV277qkV/SRrEuS/ISLwQsQS33SxWL785ZfYFqkOA0ETcta GlnA== 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 n13-20020a170902e54d00b00158643c240asi2519304plf.87.2022.06.11.02.43.54; Sat, 11 Jun 2022 02:44:06 -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 S232528AbiFKJcP (ORCPT + 99 others); Sat, 11 Jun 2022 05:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiFKJcO (ORCPT ); Sat, 11 Jun 2022 05:32:14 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 953801CE; Sat, 11 Jun 2022 02:32:11 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id B9D401E80D77; Sat, 11 Jun 2022 17:31:16 +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 cZ7eIsdfn8sV; Sat, 11 Jun 2022 17:31:14 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 4F8361E80D70; Sat, 11 Jun 2022 17:31:13 +0800 (CST) From: Li Qiong To: Davidlohr Bueso , "Paul E . McKenney" , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, hukun@nfschina.com, qixu@nfschina.com, yuzhe@nfschina.com, renyu@nfschina.com, Li Qiong Subject: [PATCH] rcu: Handle failure of memory allocation functions Date: Sat, 11 Jun 2022 17:30:55 +0800 Message-Id: <20220611093055.1473-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_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 Add warning when these functions (eg:kmalloc,vmalloc) fail, handle the failure. Signed-off-by: Li Qiong --- 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); 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