Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp689927rwb; Wed, 16 Nov 2022 06:30:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5XHzhzuRzyHjjQ+9CNMquBZ++ZdR9y02ie+rhrOC/lvhthe8WhiMGRvDlvNhAVMxinbdbu X-Received: by 2002:a17:906:1597:b0:7ad:ba48:7e7f with SMTP id k23-20020a170906159700b007adba487e7fmr17539126ejd.215.1668609027803; Wed, 16 Nov 2022 06:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668609027; cv=none; d=google.com; s=arc-20160816; b=UF3OP9/oGD6X58MhZfCTIY+OtewvKwmiggjnG2KYazPGS1yfwB2yuLHL38klcQHX5w islzOv94cuwRtDV1vEJUOamdZZ6/+mLoxnqCqIkVxWziPMzfurA5+g8c9e146yW+1hMb JtQS+2DleX5evnqq1jEKg7c9tHvvz4aIaItvwsH2dwe9Q52Hy6TCZ5PPN2HbdDR1dvGl Xq6IdIV56niWtbUR0Y9grsYm9+2ttHI3sNMDU0liNnmqaQRkwWLSPRbLHH3GdEvjRcpO yr8nXHVnuChVctkSxg7RLjEusClQDk8YTxMReYIMo0bCe3PMuMKTfNnOju2bevX/0TOp +8bw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/ioez8VUcSlWVNbQjB1Und5UiIzaRNAJj9DXCBJHb9M=; b=A7kMJpr3YZTKLPrQz6Bw2Qc4xq+gs5hNQhi6jq+tCOfeAG9mc5W2+LsY4KaT0dYQKX 55jJBGgLe50CcQYyLuej1TeGCHlWq9fo4clofRhHKJBhZN5BHdyztWpZe1z52uPVmS6u kFWDyhUlLkDqrceZRKK73xha0SHnmuJ/LG9dmut1doMMqqcYr5Zt2sFeLp5bSeQLiQiH Qi/WHTMqDUHyaBtI4DnHvGTgNQDqxbnDXX8PCOmonRrKXBfClQhulihf7zMQrML7RJFm vnHXQEcOuPLbfVXPTxmOK8qMpdumUgJ/5KzHX80kmXHYyHCXyGuFIU3qpi3HW6kufMVO Qvyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=APgYikfU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js6-20020a17090797c600b0073dda1430b9si15493223ejc.403.2022.11.16.06.30.03; Wed, 16 Nov 2022 06:30:27 -0800 (PST) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=APgYikfU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbiKPOK0 (ORCPT + 91 others); Wed, 16 Nov 2022 09:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbiKPOKE (ORCPT ); Wed, 16 Nov 2022 09:10:04 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85051FD0A; Wed, 16 Nov 2022 06:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668607757; x=1700143757; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1OaOIu1mrFQ4zu6rv6sozmi4ljbU3P7SVUDNEHsGdgY=; b=APgYikfU4pRYnFkFlzeAVLk7WIx5bduobAqn5JPXoLAdis8nxfpgnn2R s4GBaSVR4ERyF3xWBEJpQrXVsk/fxbgZWbIBIdwIunnM2tARGKWJlUpuB zwU3C8/6LKcX9DkvnOCaJpRLa5uScVaaREJ4gaFq2GY9AH6qDYSiPtvmH DmgPt3lC+Z1sRq7WW6axIra+tGvqVq3d+1MYtZJu/y2bv+V1VHIicF6v+ KuBWfPK10xRexvEQmKGk7hdz+VcdAkJRi3UEwyTpaAUHLPZXpdMQXxx2t CkXUAUXPgwdDRcPvi1TV+HzDyUqXn7iQTesb5GatFaFJ4LGkxsJjOtOO7 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="312556931" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="312556931" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 06:09:17 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="814096692" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="814096692" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.129]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 06:09:15 -0800 From: Zqiang To: paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org, thunder.leizhen@huawei.com Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu: Make vmalloc_dump_obj() call in a preemptible context Date: Wed, 16 Nov 2022 22:15:11 +0800 Message-Id: <20221116141511.3695680-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE 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 Currently, the mem_dump_obj() is invoked in call_rcu(), the call_rcu() is maybe invoked in non-preemptive code segment, for object allocated from vmalloc(), the following scenarios may occur: CPU 0 tasks context spin_lock(&vmap_area_lock) Interrupt context call_rcu() mem_dump_obj vmalloc_dump_obj spin_lock(&vmap_area_lock) <--deadlock and for PREEMPT-RT kernel, the spinlock will convert to sleepable lock, it also make vmap_area_lock spinlock can not acquire in non-preemptive code segment. therefore, this commit make the vmalloc_dump_obj() call in a preemptible context. Signed-off-by: Zqiang --- mm/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/util.c b/mm/util.c index 12984e76767e..465f8b8824ca 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1124,8 +1124,12 @@ void mem_dump_obj(void *object) return; } - if (vmalloc_dump_obj(object)) - return; + if (is_vmalloc_addr(object)) { + if (preemptible() && vmalloc_dump_obj(object)) + return; + type = "vmalloc memory"; + goto end; + } if (virt_addr_valid(object)) type = "non-slab/vmalloc memory"; @@ -1135,7 +1139,7 @@ void mem_dump_obj(void *object) type = "zero-size pointer"; else type = "non-paged memory"; - +end: pr_cont(" %s\n", type); } EXPORT_SYMBOL_GPL(mem_dump_obj); -- 2.25.1