From patchwork Thu Nov 9 11:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 13450942 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6C6819445 for ; Thu, 9 Nov 2023 11:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="wXQ7A2Im" Received: from esa15.fujitsucc.c3s2.iphmx.com (esa15.fujitsucc.c3s2.iphmx.com [68.232.156.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DBD61716 for ; Thu, 9 Nov 2023 03:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj1; t=1699529191; x=1731065191; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=onLr0RedqTvkP0zBVuVXMM2wMacWkJLcADnQNARQHWA=; b=wXQ7A2ImdEpeYhOZ4xF7skrNmgE7SwZmKoM5wwHhCMpHoYx7g18ptWSS X3GL195w3BA+WYJwNi6iozIoGTlBnzRhCyqUhq7Wyzfsnv1e5+KoVFemN 1qubYnxrHdfiBi4zM5n594IhODY+qBApkMVyTn7m1hVBYycKxvurJDGPU yqyeAYQ+9TiTaFqb1+anBksC4P+Wyf64nUn/JGH3/qVg5NvfVccItlANV ctoaiKnL9RuvurF/RlNrkJcm+5T3iinTMzlyjaTNfSWmGix/1GUMQfKh+ vhHUMmbVPYBwec9O2YUOvNGKcR9q5HJIgCl7GU2UYXT8h8PnM3VWTwzMa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="102100719" X-IronPort-AV: E=Sophos;i="6.03,289,1694703600"; d="scan'208";a="102100719" Received: from mail-os0jpn01lp2105.outbound.protection.outlook.com (HELO JPN01-OS0-obe.outbound.protection.outlook.com) ([104.47.23.105]) by ob1.fujitsucc.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 20:26:26 +0900 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=knsvlhFrVDEgmHHg+tKf29hhQsdJn5Tl9gJzu8uHpk2A54LKY7w3cBwILUmaSk6Cy0B/expIxz5GKMXH5iDlq1c971j+a1ynbfcV0hH55fmWrioCUf/rOdkVQDx64OngfHPagSeUMFq0WNTyJQ61yzHh7xLew2xz8oJntADcyNjgR7sfRGhohIQyLimbnxh0aGCSej1H49MHYg8NK+jFhPhjxtfl/LkdTgakKnC2Eiwc92KKQ6OfDpqd5c6XpH6PQw/FJicqEU4EcI1NGQcD3sF/OXIc06koMfrMl6OeTAmNs5nXhzeCUIsJfHgdZssmDTY3I+PaPRina6f1EQWeBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=onLr0RedqTvkP0zBVuVXMM2wMacWkJLcADnQNARQHWA=; b=a8XWRyUK1CF350ttnZpRPEtifKWmTq6QuQDz5AKLYlfx9uFUhwZszmZyFus7KSYs9D+vVGr3DP43qeSEHde+C/dSPgQmQrihwCiNJFVTw3aIkDeZf70Hhionbwv/bxCzZshdbVY2s208xN3WsqcsCN3YVxvHoTexcBE7Z4aiYXswqej/XDcfaYphsm5cXQ34XjgLGA0VCwM8zkGAxpXC8DVRRAQBp3C3So78PZLcstr5N0eo3DJ6djOoWfPyoJ9I99mLk5HkDupC+7Ysod2oUD6vMrnQx85/n0gn3JUYHlVT2wbWLyNSa6+KoSCysi7cRz1veMmnXZwBhlNr7sg48A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fujitsu.com; dmarc=pass action=none header.from=fujitsu.com; dkim=pass header.d=fujitsu.com; arc=none Received: from TYWPR01MB10743.jpnprd01.prod.outlook.com (2603:1096:400:2a7::9) by OS3PR01MB7801.jpnprd01.prod.outlook.com (2603:1096:604:17b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19; Thu, 9 Nov 2023 11:26:22 +0000 Received: from TYWPR01MB10743.jpnprd01.prod.outlook.com ([fe80::8ee1:4e5b:c45f:dd6b]) by TYWPR01MB10743.jpnprd01.prod.outlook.com ([fe80::8ee1:4e5b:c45f:dd6b%4]) with mapi id 15.20.6977.018; Thu, 9 Nov 2023 11:26:22 +0000 From: "Xiao Yang (Fujitsu)" To: Dave Jiang , "vishal.l.verma@intel.com" CC: "linux-cxl@vger.kernel.org" , "nvdimm@lists.linux.dev" , "dan.j.williams@intel.com" Subject: =?utf-8?q?=E5=9B=9E=E5=A4=8D=3A_=5BNDCTL_PATCH_v3=5D_cxl/region=3A_?= =?utf-8?q?Add_-f_option_for_disable-region?= Thread-Topic: [NDCTL PATCH v3] cxl/region: Add -f option for disable-region Thread-Index: AQHaDEAj9CkOpNIeKEi5Q7RzVuVUO7Bx5bNw Date: Thu, 9 Nov 2023 11:26:22 +0000 Message-ID: References: <169878724592.82931.11180459815481606425.stgit@djiang5-mobl3> In-Reply-To: <169878724592.82931.11180459815481606425.stgit@djiang5-mobl3> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: =?utf-8?q?MSIP=5FLabel=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050?= =?utf-8?q?=5FActionId=3Dbf9bc2e5-5dce-4a1f-8a15-6ce9586d8cd2=3BMSIP=5FLabel?= =?utf-8?q?=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050=5FContentBits=3D0=3BMSIP?= =?utf-8?q?=5FLabel=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050=5FEnabled=3Dtrue?= =?utf-8?q?=3BMSIP=5FLabel=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050=5FMethod?= =?utf-8?q?=3DStandard=3BMSIP=5FLabel=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050?= =?utf-8?q?=5FName=3DFUJITSU-RESTRICTED=E2=80=8B=3BMSIP=5FLabel=5Fa7295cc1-d?= =?utf-8?q?279-42ac-ab4d-3b0f4fece050=5FSetDate=3D2023-11-09T11=3A23=3A01Z?= =?utf-8?q?=3BMSIP=5FLabel=5Fa7295cc1-d279-42ac-ab4d-3b0f4fece050=5FSiteId?= =?utf-8?q?=3Da19f121d-81e1-4858-a9d8-736e267fd4c7=3B?= authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fujitsu.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYWPR01MB10743:EE_|OS3PR01MB7801:EE_ x-ms-office365-filtering-correlation-id: fd606091-8fb8-4e1f-5ba0-08dbe116b3bd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4l0cSPjrnZl7AUkNhH8VYOwIGtkyas0MU+74uJYq6jjVGPG4X9NPjIykl9iG4g1NxLYHeEyHBNEdIWyhx8tUVCxRfQ/BzWkVcRDdLI7Vkqh8yrdnapceLaZxXH9SM6TH14zk6cCIkDTKYeN/6mBROY3LPL5F+782/RwS79TKfCYuS7uePWRVTqmSkbS3Gavi2JuyPJtvtXDi7aAmBtf+xX7H63F8R/xs7zhjTLQXS0hFHdJZX+culi54GHEVKwa988S8OyWeHchj2vNzoL6Y44RdwhQlolhpe76+GqYN9mt9/PAJ2hmLZL81DSsyS6UECT0bcshCVQaoT/inOuYS1wuS+mAe9t6v0XDjEdBFIwN6KHVLKD211TJo6pJTzvqat7xgdeYlVbLw9ysAouCCV+kgGhtjefe/GntyzjwLG4ipq+eMGJMs3twAkzUUIkBfikiKqerwwFXDFmQ6R9qnvHMOx1Q8NBzd1hwaZUr34vFe5dkNq7gasbHymtB/dAM8lq9DCEufbKZaPsfFmYP5Ry10MUKvcjPVwZe1Oui1B4E9f3UwsHySi7AWN88wGonEuzYfPIlRPiS2gjFGvJg+uNALdbfwcSlLzclkX1a6GF8I/YPblZ8AhQNmw04VRXIZ1JkCMvZFa/FMNmHdM8ACC7XwRsmOT/66noK4hWF0zRhxBl6J4ynqoQBkN8YWVHse x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYWPR01MB10743.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(366004)(396003)(230273577357003)(230922051799003)(230173577357003)(1800799009)(186009)(1590799021)(451199024)(64100799003)(55016003)(1580799018)(66946007)(76116006)(66556008)(66446008)(54906003)(316002)(110136005)(64756008)(66476007)(224303003)(85182001)(86362001)(33656002)(38070700009)(38100700002)(122000001)(82960400001)(9686003)(83380400001)(26005)(71200400001)(7696005)(6506007)(2906002)(478600001)(8936002)(41300700001)(52536014)(4326008)(5660300002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?V8OuHJLLemP3oNWRq/XqK4KHDTqx?= =?utf-8?q?njeIgVkwMvjjkdYjnHBe5+NcmDyLp/plMCuH0I23QJvKIvy4I4qNvxFelMLIU6nx8?= =?utf-8?q?N7EDdIJUG0naefKBJu0FgEIOvDyyaQGEuRX/XEnVlvFe30HGvTpXAUnGN9HuDgfzB?= =?utf-8?q?OZsCrxmBOf6tlCxWzommUPhbHivvzNVGgn40PNAoNQyC2yfdIIewPFC9VSJ+/vP0w?= =?utf-8?q?XJclqNMomKwU0HWAqzkgQlA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zXxZieft+RRRbm34+5z?= =?utf-8?q?WIk0AJOVhqtGLLBib5ty03IR8KCHMCL99ZmYZUAwxRaFrHGCpa07TzBOI31fS+4Qg?= =?utf-8?q?x37pHPhXg6VoVN9ux58x8Iv0U+BQaVbASePj8hGcTySCJXOUp3iTIE3oE48luLT0q?= =?utf-8?q?dYFdG4XtfPQOcelyswgPvAIT1u5Gas5rrBFA3bSq8j4/ldKoF7RicSqdWClmRPEsM?= =?utf-8?q?smWkmtFIAWHhxST9gyWPjiRzFvBXiyIpEEpATAdDS+gGn6ZUxJLCS+xvysWQxDjvK?= =?utf-8?q?UATYSCcfnf4/uidg/VqexZJH0TBleha1m1nkbkuLGqZFVPcey9f06mZnO6Jddghcu?= =?utf-8?q?Kovfv9XewrICVkZRSUkGbpsK3Fv96hxq+CPoqcxBGE4v0EkcjTdDtELvRLrMA5P15?= =?utf-8?q?gYgMAKhdpUzX?= Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2sOLXBohW8yI5iCgbdWNcV27GeggbU/SuHyz85qPKpGukrICDSakuKea3w8456UKH7yiGGbtaO4xib0fGOwn5zvXN05Tnw1v4jVRMV5q7XQt2T1N0NRiZlm1qTvfZQ4KhuvxPpUSTJNA2dTzWUCrriVtfCSqKw4WTtukE0ynvSJNfnmzo8YrRqzJL3eLvxmViLRga4qZhfNoVx7+IFqVR/8Mu7Lm30/WQcLLt2hdsop82gPUk3KCok0vTNIqiz2uhWEPkF2fnSMHcWQtlKs2vzmVWDvk2kwEcK+sat/Iayel9S+RWB/AIDGD1UhRkEBo/iQwRammSAnYNROMLVCrv0hDJeLdtJXdboHhiRvlt+O9LfvcZrXXhv80a0StALll0OO6DkXfpyqu6lIxZQckCRfIRQib6xK7SN3YJ+Ov6S9gMmvSUo6yc2AnejX9Zv/KSHROivX58pyRrBE0IA5xYcuoqTJg5qB6Jexi6undY9m7kynNsgr2rQKl/l1U5hlWXIDGrYlnwJobr48hEg7nkRFFTC6XjcztJ9rLlk6ySdGNIe2iy2FSoaG7IiM8E9+iD95ON7EVJH1gax0FQ9Lt6FEb0vEbI2DTTswjdUMlIV/gLK3gCkhN/UqXVe6C6ZJ9yvbqPoHjTJO9DEDB79hRuZxu81mtSexlDpOBnlwEFz0FPBl4n8oR+9NrUFJFxaSt3XAlV9el/9fkK+5C7dnOYpdeAAkIYZhHVWI6DbIKeVEZptRJZ5VlW7rFNDAnrcpHHjdleLBkh4QtVKJCehcpcL+Km1WLAyWnGd/xoOJ87ByNbUIN0JtCkZH3Wd23OkN5XmiFfTlLMLz6GMgNXxotxg== X-OriginatorOrg: fujitsu.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYWPR01MB10743.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd606091-8fb8-4e1f-5ba0-08dbe116b3bd X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2023 11:26:22.3874 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a19f121d-81e1-4858-a9d8-736e267fd4c7 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NKoMn0qeyL55bSPbZkOi5CGLmFLO3rhwgmXbAPWkBRszrFQn/8iNJ71ebYuqps4EUMdPndNQUWCz55RAw2txHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB7801 Hi Dave, Thanks for your v3 patch. We have tested the patch on our environment, it works well. Reviewed-by: Xiao Yang Tested-by: Quanquan Cao Best Regards, Xiao Yang -----邮件原件----- 发件人: Dave Jiang 发送时间: 2023年11月1日 5:21 收件人: vishal.l.verma@intel.com 抄送: linux-cxl@vger.kernel.org; nvdimm@lists.linux.dev; dan.j.williams@intel.com; Yang, Xiao/杨 晓 主题: [NDCTL PATCH v3] cxl/region: Add -f option for disable-region The current operation for disable-region does not check if the memory covered by a region is online before attempting to disable the cxl region. Have the tool attempt to offline the relevant memory before attempting to disable the region(s). If offline fails, stop and return error. Provide a -f option for the region to continue disable the region even if the memory is not offlined. Add a warning to state that the physical memory is being leaked and unrecoverable unless reboot due to disable without offline. Signed-off-by: Dave Jiang --- v3: - Remove movable check. (Dan) - Attempt to offline if not offline. -f will disable region anyways even if memory not offline. (Dan) v2: - Update documentation and help output. (Vishal) --- Documentation/cxl/cxl-disable-region.txt | 10 ++++++ cxl/region.c | 54 +++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Documentation/cxl/cxl-disable-region.txt b/Documentation/cxl/cxl-disable-region.txt index 4b0625e40bf6..9abf19e96094 100644 --- a/Documentation/cxl/cxl-disable-region.txt +++ b/Documentation/cxl/cxl-disable-region.txt @@ -14,6 +14,10 @@ SYNOPSIS include::region-description.txt[] +If there are memory blocks that are still online, the operation will +attempt to offline the relevant blocks. If the offlining fails, the +operation fails when not using the -f (force) parameter. + EXAMPLE ------- ---- @@ -27,6 +31,12 @@ OPTIONS ------- include::bus-option.txt[] +-f:: +--force:: + Attempt to disable-region even though memory cannot be offlined successfully. + Will emit warning that operation will permanently leak phiscal address space + and cannot be recovered until a reboot. + include::decoder-option.txt[] include::debug-option.txt[] diff --git a/cxl/region.c b/cxl/region.c index bcd703956207..5cbbf2749e2d 100644 --- a/cxl/region.c +++ b/cxl/region.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "filter.h" #include "json.h" @@ -95,6 +96,8 @@ static const struct option enable_options[] = { static const struct option disable_options[] = { BASE_OPTIONS(), + OPT_BOOLEAN('f', "force", ¶m.force, + "attempt to offline memory before disabling the region"), OPT_END(), }; @@ -789,13 +792,62 @@ static int destroy_region(struct cxl_region *region) return cxl_region_delete(region); } +static int disable_region(struct cxl_region *region) { + const char *devname = cxl_region_get_devname(region); + struct daxctl_region *dax_region; + struct daxctl_memory *mem; + struct daxctl_dev *dev; + int failed = 0, rc; + + dax_region = cxl_region_get_daxctl_region(region); + if (!dax_region) + goto out; + + daxctl_dev_foreach(dax_region, dev) { + mem = daxctl_dev_get_memory(dev); + if (!mem) + return -ENXIO; + + /* + * If memory is still online and user wants to force it, attempt + * to offline it. + */ + if (daxctl_memory_is_online(mem)) { + rc = daxctl_memory_offline(mem); + if (rc < 0) { + log_err(&rl, "%s: unable to offline %s: %s\n", + devname, + daxctl_dev_get_devname(dev), + strerror(abs(rc))); + if (!param.force) + return rc; + + failed++; + } + } + } + + if (failed) { + log_err(&rl, "%s: Forcing region disable without successful offline.\n", + devname); + log_err(&rl, "%s: Physical address space has now been permanently leaked.\n", + devname); + log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n", + devname); + } + +out: + return cxl_region_disable(region); +} + static int do_region_xable(struct cxl_region *region, enum region_actions action) { switch (action) { case ACTION_ENABLE: return cxl_region_enable(region); case ACTION_DISABLE: - return cxl_region_disable(region); + return disable_region(region); case ACTION_DESTROY: return destroy_region(region); default: