Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1899826rwb; Thu, 17 Nov 2022 03:52:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7fUkXJ2VCqhhUPyusbQMNMFjBTIv4E/HHfYQEru/kvfoy7rv9iQSdgfAvlYJN1wIMeF3zJ X-Received: by 2002:a17:90a:fb8c:b0:218:72dd:fad with SMTP id cp12-20020a17090afb8c00b0021872dd0fadmr2325750pjb.53.1668685927886; Thu, 17 Nov 2022 03:52:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668685927; cv=none; d=google.com; s=arc-20160816; b=mAfjagyMaU8+bKqGMWp4QoMgQ0SF+8P8PmqDVtbTYnZeK7BUKlasqMC2fG+h39UkXN cpm4nFc4CCDjiavemTrTZit4YvK0tPkI+JlDVoeQqx2dpAq6fm36qdCn4m+Tuo2tAVYN vc7tUJKY095KJ3lP644CQ4AS68Anmvfd2kjbeYjj/7k1AJoRDwGSXNSzPqmRwwRGWfcg Am1de+ciyQsnpJDUyKLz/uge83ODI2HeKL/phYOEzfE6vM7nFRwIBVdetOqKmM9Yuitm K1t/c3CopwjqPdy95C39BKJh7uqP0cVJuiOKDuCwtK7s0z07XypkL+uECGxSM7Sy+FrI cGrQ== 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=0w7d69wQk5jMFAALtDtEORhhUDkIpqPIGUPd13Q8FOI=; b=rsrVc2nSbl5IEjYvuS1k29uOqpY1l11Miv3JvkVRKJUpdV6zzzM5Np2QxrAM2udMfz iiQ7rETwnllcZMnDlO44GWAFxT+Yzfm2Q3aAyIh1pBa3bFREjamS9K/stGutyNdZHNwM oqT8Rf2nOaVa3M8r14ExUHlS9qnG8seang19882GaGzFr7b6HWHRvdYI9YepA1kaXXnS Cv04o5GkBZkBihs7PtJGq0OJEd/d4tMtqhZ31gr3oNRvYRVu1JVqC1k/1P4fKGjobdtK DfWMK/PKY8zV0KqyLszwgr4/5sQrppr51uw7z9xY6eaAAaw+vCgCya1orhnh6ncUjhCY KiFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FrbBE4mb; 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 e5-20020a17090301c500b00186c41eced7si935408plh.36.2022.11.17.03.51.56; Thu, 17 Nov 2022 03:52:07 -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=FrbBE4mb; 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 S234851AbiKQLTf (ORCPT + 92 others); Thu, 17 Nov 2022 06:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239668AbiKQLT3 (ORCPT ); Thu, 17 Nov 2022 06:19:29 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB972B251; Thu, 17 Nov 2022 03:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668683967; x=1700219967; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=R7Tw/bo/e0ph1HCAxMg1wWzO55ZqQuYAf2pd0W+MSkw=; b=FrbBE4mbJXnFogg+pl0S1qnwtECG82+HREd9SjRsRyzkf8cwRaHzMCBK uJ8T/zWZJyUzPUkcJ81QaNyMg6DRa+Yx2LC7OtImv5yi2I5xVIyPxl0KN 3RQaDtwlE/DT6ly++h4Bzu5apV8XLowwoOsD2fwdZD6rwOqktQ3snfFvH tuMx0thSkdKgN6i/e5b2laXdeBkmt38pluteCuI3glEy+qP8bTyFM5UxV RU6LfYqPzz2aw/YUes10B3Xk7ouQiyYS50UaTxsXkJAEvGbUyFZYN/LU2 9MKBTBj8FUImBr3Yy8b0u8/i+0mBIUyB1uGwRK+ZcBPUERpvWNeI264to A==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="377090197" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="377090197" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 03:19:27 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="642063469" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="642063469" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.129]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 03:19:24 -0800 From: Zqiang To: paulmck@kernel.org, thunder.leizhen@huawei.com, akpm@linux-foundation.org, frederic@kernel.org, joel@joelfernandes.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mm: Make vmalloc_dump_obj() call in a preemptible context Date: Thu, 17 Nov 2022 19:25:20 +0800 Message-Id: <20221117112520.3942618-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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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, so the vmap_area_lock spinlock not allowed to get in non-preemptive code segment. therefore, this commit make the vmalloc_dump_obj() call in a preemptible context. Signed-off-by: Zqiang --- v1->v2: Add IS_ENABLED(CONFIG_PREEMPT_RT) check. mm/util.c | 4 +++- mm/vmalloc.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index 12984e76767e..2b0222a728cc 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1128,7 +1128,9 @@ void mem_dump_obj(void *object) return; if (virt_addr_valid(object)) - type = "non-slab/vmalloc memory"; + type = "non-slab memory"; + else if (is_vmalloc_addr(object)) + type = "vmalloc memory"; else if (object == NULL) type = "NULL pointer"; else if (object == ZERO_SIZE_PTR) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ccaa461998f3..018e417b12d6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4034,6 +4034,10 @@ bool vmalloc_dump_obj(void *object) struct vm_struct *vm; void *objp = (void *)PAGE_ALIGN((unsigned long)object); + if (!is_vmalloc_addr(objp) || ((IS_ENABLED(CONFIG_PREEMPT_RT) && + !preemptible()) || in_interrupt())) + return false; + vm = find_vm_area(objp); if (!vm) return false; -- 2.25.1