From patchwork Fri Dec 15 05:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 179034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9055814dys; Thu, 14 Dec 2023 21:26:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaXU9e9FlBz2yyWE9f9BrmDz5CCkdkd6ebKiFVG/Voe1QjGXFSN6DMnPB+75D2D8f05kIy X-Received: by 2002:ac2:46c5:0:b0:50b:f0af:5605 with SMTP id p5-20020ac246c5000000b0050bf0af5605mr4912800lfo.102.1702618007797; Thu, 14 Dec 2023 21:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702618007; cv=none; d=google.com; s=arc-20160816; b=LANSE8aKLDG4S8V16DH+Ezs+EUfB2yFap1QIUC9hdbqS6gMAc9qN6RyE9uRkM56hRW ZPN1xUfjAb0H5fHB/SQ4A4m+TeLuXgpN8EkObdz6ZDJS73Zq4cqhU5ZbsghtCaEbLj3t vLo++AuSOiaL6xFWa3goJ05By8u0iWGDzdu7mETBBc0LjVB+ywTWHC0OQ+RnQ8fKlVCi Jm38opNzWtVG3WevlbxfxPdD3MJ8UPXStH1uK7dbRFLzCWIhRjcMq7c+/onQCZKK3iDr YDHAdDAhRjkXrT4i1X+o4vIoqs4jvYmMAcVaeBzeMwHXo/eRevTDSQ27IAC4IF2HEXoA l64w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=akSvxKH89lALLTdkFCxz3zg9y9c/WbifuO3VvS8K3bg=; fh=I3mwi+I+wtOTQR1sA96WuVxJI4ZptzU51sgs9g/h52k=; b=dtvAjg+7RiquwXqJIqVwbjlyHrI9uo4wEC1GewBCrbOo/sVJYkARZc/3CGtsmYIcFR YgFj2zIPB6cB9mIVvU7jR6kdhgDktWq4aV68jHW1QfNx8cldAe0G8esskR4nsJ2U6OdW yh67cZjYAFM/UdsoBMo9zt5Z4vuE8r9HbxwLFowlnNOLkhAijlsnxwSOdr2XRjVhKtMv euArgp/lpvT5eTmsq4wc8v76kQcegVqjOTk+6QZZMTlbliYdpxBkBU8pQLIdQWMRD50f vhlw7gehQI3VbTtiTY/k004sgc3p/dyToP5cPnRhJYpD44KoG7KbIhjrbgJZU3XEHrl8 7VrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OG3e4dnb; spf=pass (google.com: domain of linux-kernel+bounces-444-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-444-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f8-20020a170906138800b00a1ce98016c1si7171843ejc.394.2023.12.14.21.26.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:26:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-444-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OG3e4dnb; spf=pass (google.com: domain of linux-kernel+bounces-444-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-444-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 19FAB1F22A49 for ; Fri, 15 Dec 2023 05:26:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1D6D101C3; Fri, 15 Dec 2023 05:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OG3e4dnb" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 92062610D; Fri, 15 Dec 2023 05:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702617939; x=1734153939; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=s2pn4yZl0XYTp65Nn5lvuI7n/QI1GItpUEXHrwpjM9A=; b=OG3e4dnb2BSAf1cj3mIxpLkpE6FkMQE5ju3zK9kMtC1BfYRGoqJqNQuw IW5XrMKoPSbZdl+IHCqeKRbCWa/H/QKzah5OOmxdICNk7+B6wnSt/A6EZ BWDS5M6PEzaeRv1bZo2SCHvfDAGeOtu9sdSgg+LkwMAnl4p74KJm9zrb8 r0uwhA4Uj+v9tjV7czgvnOyLbT3jOOI7q9azucUlfRt7czmT1uBP9ssKR 6gX4mxce+lDqjkZG9fqaVpRJGYwQSBAbc7MxlC02uXsCmR1nZaX0RyaoL gi7IjbIw3aL+gc2Ahb6yd4w6wEPUHTCGIjfZwkC3e1Y6baRf3O6cVsv0z g==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461695015" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="461695015" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="808847933" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="808847933" Received: from mmtakalk-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.109.101]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:37 -0800 From: Vishal Verma Date: Thu, 14 Dec 2023 22:25:26 -0700 Subject: [PATCH v6 1/4] Documentatiion/ABI: Add ABI documentation for sys-bus-dax Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231214-vv-dax_abi-v6-1-ad900d698438@intel.com> References: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> In-Reply-To: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=5934; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=s2pn4yZl0XYTp65Nn5lvuI7n/QI1GItpUEXHrwpjM9A=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnVj/0r9Ttm7/2+yP7HJW9hJf/0P4+efS1lffUjJ6Pgg 9WZDomFHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZhIRDQjwxbWjft2Rj4KrVI6 9EGhPeCulr7/NHHe8/q6zTfk/Hx4Ghn+KcSHRwasT3++S+N9wN7MdKFvWmf5J5rMl49/ZXFIy1u eEwA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785324380408417197 X-GMAIL-MSGID: 1785324380408417197 Add the missing sysfs ABI documentation for the device DAX subsystem. Various ABI attributes under this have been present since v5.1, and more have been added over time. In preparation for adding a new attribute, add this file with the historical details. Cc: Dan Williams Signed-off-by: Vishal Verma --- Documentation/ABI/testing/sysfs-bus-dax | 136 ++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-dax b/Documentation/ABI/testing/sysfs-bus-dax new file mode 100644 index 000000000000..6359f7bc9bf4 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-dax @@ -0,0 +1,136 @@ +What: /sys/bus/dax/devices/daxX.Y/align +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RW) Provides a way to specify an alignment for a dax device. + Values allowed are constrained by the physical address ranges + that back the dax device, and also by arch requirements. + +What: /sys/bus/dax/devices/daxX.Y/mapping +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (WO) Provides a way to allocate a mapping range under a dax + device. Specified in the format -. + +What: /sys/bus/dax/devices/daxX.Y/mapping[0..N]/start +What: /sys/bus/dax/devices/daxX.Y/mapping[0..N]/end +What: /sys/bus/dax/devices/daxX.Y/mapping[0..N]/page_offset +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RO) A dax device may have multiple constituent discontiguous + address ranges. These are represented by the different + 'mappingX' subdirectories. The 'start' attribute indicates the + start physical address for the given range. The 'end' attribute + indicates the end physical address for the given range. The + 'page_offset' attribute indicates the offset of the current + range in the dax device. + +What: /sys/bus/dax/devices/daxX.Y/resource +Date: June, 2019 +KernelVersion: v5.3 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The resource attribute indicates the starting physical + address of a dax device. In case of a device with multiple + constituent ranges, it indicates the starting address of the + first range. + +What: /sys/bus/dax/devices/daxX.Y/size +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RW) The size attribute indicates the total size of a dax + device. For creating subdivided dax devices, or for resizing + an existing device, the new size can be written to this as + part of the reconfiguration process. + +What: /sys/bus/dax/devices/daxX.Y/numa_node +Date: November, 2019 +KernelVersion: v5.5 +Contact: nvdimm@lists.linux.dev +Description: + (RO) If NUMA is enabled and the platform has affinitized the + backing device for this dax device, emit the CPU node + affinity for this device. + +What: /sys/bus/dax/devices/daxX.Y/target_node +Date: February, 2019 +KernelVersion: v5.1 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The target-node attribute is the Linux numa-node that a + device-dax instance may create when it is online. Prior to + being online the device's 'numa_node' property reflects the + closest online cpu node which is the typical expectation of a + device 'numa_node'. Once it is online it becomes its own + distinct numa node. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/available_size +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The available_size attribute tracks available dax region + capacity. This only applies to volatile hmem devices, not pmem + devices, since pmem devices are defined by nvdimm namespace + boundaries. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/size +Date: July, 2017 +KernelVersion: v5.1 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The size attribute indicates the size of a given dax region + in bytes. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/align +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The align attribute indicates alignment of the dax region. + Changes on align may not always be valid, when say certain + mappings were created with 2M and then we switch to 1G. This + validates all ranges against the new value being attempted, post + resizing. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/seed +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The seed device is a concept for dynamic dax regions to be + able to split the region amongst multiple sub-instances. The + seed device, similar to libnvdimm seed devices, is a device + that starts with zero capacity allocated and unbound to a + driver. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/create +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (RW) The create interface to the dax region provides a way to + create a new unconfigured dax device under the given region, which + can then be configured (with a size etc.) and then probed. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/delete +Date: October, 2020 +KernelVersion: v5.10 +Contact: nvdimm@lists.linux.dev +Description: + (WO) The delete interface for a dax region provides for deletion + of any 0-sized and idle dax devices. + +What: $(readlink -f /sys/bus/dax/devices/daxX.Y)/../dax_region/id +Date: July, 2017 +KernelVersion: v5.1 +Contact: nvdimm@lists.linux.dev +Description: + (RO) The id attribute indicates the region id of a dax region. From patchwork Fri Dec 15 05:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 179035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9055888dys; Thu, 14 Dec 2023 21:27:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbCiTdO67XU9ohfdPaczqF8FEZMNwFaHvbCl9ok0eNrwrlwSg96ux6jofthE+iWPSxNw1s X-Received: by 2002:a17:90a:5108:b0:28b:1d0:2adf with SMTP id t8-20020a17090a510800b0028b01d02adfmr2028161pjh.30.1702618021807; Thu, 14 Dec 2023 21:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702618021; cv=none; d=google.com; s=arc-20160816; b=DJjBn1kNtpFrLoZLlKsQqiGJZ/HS9H2ozIUAGz363ASixdHdePVhHlIJQun+KuOo0S erAw04yVsh6y6GAhHhJwSzXrkaGxwGXcBWunMhH2K49E9za81FnnciB8MCsn0TSIFHAy 4Mi81JGDfgaqx70qM9GrSxRTfjt0pVbFLt0R8BxvD4cRV2tgJ+tOK1RHLeA/qaHwC2rk qgzMlcSa4Mb+Ioy9gP4dvbtu4CpCp08Sv118634CKSbqjEnpqhJRdPehFpmC2DNQmsWh 1i/v2WYkeWpk/kH0ISnnhxZ1LjARBqsExCSMAg5L9zFEgVU/q1Bx/5hOzYHwmoIpOXlJ 9DcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=5J+gIfvXGnhCDLBK5rZw2WLoOAKtg347Jw8tbqyeHBk=; fh=9vEQBnCyStcve6enYwr7/p6U/eaWPJ0Rrmp9q7Az4NU=; b=x/lnx+XrRToAx3yV6+YciTKkyl4InY1ZMhdFeN8RQkvAb/hONVnoJCCn47yke7JXvI pXfG2ryGTSqwCyqv2mrQ/T4Td7qJT3mdc0jkSVsPIykyAg+49lVJGc9ytHHuus+I42OK iXOObMnS//+fbkNbxH9RXGX+AqhVDBjA+3n4ALN+WY5DbzXWEdjVW5IVHbuqrf5ewbq3 wltQks8zsiU7wkl/N2Cp97Ayn8qEOKeSIKuafSlUKGoXqGA4l5alooijXqgtJGUoISbD RY9NE3C0DrM9AgtSSxIhkWKXnXYvUxEOwcDhPdu3ug4EV91+ADvCGSLYpKcZdS/ocpcz t52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvMGkubo; spf=pass (google.com: domain of linux-kernel+bounces-445-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-445-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o6-20020a17090ac70600b0028ad7bb390dsi4609191pjt.160.2023.12.14.21.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-445-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvMGkubo; spf=pass (google.com: domain of linux-kernel+bounces-445-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-445-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8EBAD284421 for ; Fri, 15 Dec 2023 05:27:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAAEC107BB; Fri, 15 Dec 2023 05:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fvMGkubo" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 78A1563B8; Fri, 15 Dec 2023 05:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702617940; x=1734153940; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=g9l8RslOMp5ad/gXCRHw+j360xuk1nb3+acdwFrlL50=; b=fvMGkubomAMD/MJfSMlJqb3MqwS+58jQzk6tsPXc8bdn2rn3egZpBTyZ DiWxatUcux5+fgTtvMPD6TNHnqTK5gCkq8l0ln9O23TAEj9sGMDdYnuHP Gs7znb4A4EoXQq4uILh/YpuF8wv4lxuKLKK/BZHbbhZR6VPZLKZBL9oFc Xj6jkgjslv96PJedaI9YGEx8M2fWgyMkPpa3g6PVFVSdLYwdrfB0ty8p1 +029a1EmXJ2dQdoCY2UYoyh0XaiqMauo0b96sDT3AgxBVPGAtosysVv/M ov2IUJVUalOiGDr0qGptzavBW8gSecVjT+kHB58HuCEnxXgxYzERjhiAV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461695023" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="461695023" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="808847937" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="808847937" Received: from mmtakalk-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.109.101]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:38 -0800 From: Vishal Verma Date: Thu, 14 Dec 2023 22:25:27 -0700 Subject: [PATCH v6 2/4] dax/bus: Use guard(device) in sysfs attribute helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231214-vv-dax_abi-v6-2-ad900d698438@intel.com> References: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> In-Reply-To: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org, Joao Martins X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=7001; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=g9l8RslOMp5ad/gXCRHw+j360xuk1nb3+acdwFrlL50=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnVj/23PV4Tsi/68R5Hl9unM3Y0djytWdHAbcGkJ6wik Xx6GsP5jlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEykr57hf0DG/93heXPCGta+ VdH15phpYq+zb1lQoDBvzzV7Xmm3bEaG70EflVMniO1OexLerz/H53mywgcvmXW6Pzq2vT/JGvK bGQA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785324394439551678 X-GMAIL-MSGID: 1785324394439551678 Use the guard(device) macro to lock a 'struct device', and unlock it automatically when going out of scope using Scope Based Resource Management semantics. A lot of the sysfs attribute writes in drivers/dax/bus.c benefit from a cleanup using these, so change these where applicable. Cc: Joao Martins Cc: Dan Williams Signed-off-by: Vishal Verma Reviewed-by: Jonathan Cameron --- drivers/dax/bus.c | 143 ++++++++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 84 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 1ff1ab5fa105..6226de131d17 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -294,13 +294,10 @@ static ssize_t available_size_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dax_region *dax_region = dev_get_drvdata(dev); - unsigned long long size; - device_lock(dev); - size = dax_region_avail_size(dax_region); - device_unlock(dev); + guard(device)(dev); - return sprintf(buf, "%llu\n", size); + return sprintf(buf, "%llu\n", dax_region_avail_size(dax_region)); } static DEVICE_ATTR_RO(available_size); @@ -309,17 +306,14 @@ static ssize_t seed_show(struct device *dev, { struct dax_region *dax_region = dev_get_drvdata(dev); struct device *seed; - ssize_t rc; if (is_static(dax_region)) return -EINVAL; - device_lock(dev); + guard(device)(dev); seed = dax_region->seed; - rc = sprintf(buf, "%s\n", seed ? dev_name(seed) : ""); - device_unlock(dev); - return rc; + return sprintf(buf, "%s\n", seed ? dev_name(seed) : ""); } static DEVICE_ATTR_RO(seed); @@ -328,24 +322,28 @@ static ssize_t create_show(struct device *dev, { struct dax_region *dax_region = dev_get_drvdata(dev); struct device *youngest; - ssize_t rc; if (is_static(dax_region)) return -EINVAL; - device_lock(dev); + guard(device)(dev); youngest = dax_region->youngest; - rc = sprintf(buf, "%s\n", youngest ? dev_name(youngest) : ""); - device_unlock(dev); - return rc; + return sprintf(buf, "%s\n", youngest ? dev_name(youngest) : ""); } static ssize_t create_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct dax_region *dax_region = dev_get_drvdata(dev); + struct dev_dax_data data = { + .dax_region = dax_region, + .size = 0, + .id = -1, + .memmap_on_memory = false, + }; unsigned long long avail; + struct dev_dax *dev_dax; ssize_t rc; int val; @@ -358,38 +356,25 @@ static ssize_t create_store(struct device *dev, struct device_attribute *attr, if (val != 1) return -EINVAL; - device_lock(dev); + guard(device)(dev); avail = dax_region_avail_size(dax_region); if (avail == 0) - rc = -ENOSPC; - else { - struct dev_dax_data data = { - .dax_region = dax_region, - .size = 0, - .id = -1, - .memmap_on_memory = false, - }; - struct dev_dax *dev_dax = devm_create_dev_dax(&data); + return -ENOSPC; - if (IS_ERR(dev_dax)) - rc = PTR_ERR(dev_dax); - else { - /* - * In support of crafting multiple new devices - * simultaneously multiple seeds can be created, - * but only the first one that has not been - * successfully bound is tracked as the region - * seed. - */ - if (!dax_region->seed) - dax_region->seed = &dev_dax->dev; - dax_region->youngest = &dev_dax->dev; - rc = len; - } - } - device_unlock(dev); + dev_dax = devm_create_dev_dax(&data); + if (IS_ERR(dev_dax)) + return PTR_ERR(dev_dax); - return rc; + /* + * In support of crafting multiple new devices simultaneously multiple + * seeds can be created, but only the first one that has not been + * successfully bound is tracked as the region seed. + */ + if (!dax_region->seed) + dax_region->seed = &dev_dax->dev; + dax_region->youngest = &dev_dax->dev; + + return len; } static DEVICE_ATTR_RW(create); @@ -481,12 +466,9 @@ static int __free_dev_dax_id(struct dev_dax *dev_dax) static int free_dev_dax_id(struct dev_dax *dev_dax) { struct device *dev = &dev_dax->dev; - int rc; - device_lock(dev); - rc = __free_dev_dax_id(dev_dax); - device_unlock(dev); - return rc; + guard(device)(dev); + return __free_dev_dax_id(dev_dax); } static int alloc_dev_dax_id(struct dev_dax *dev_dax) @@ -908,9 +890,8 @@ static ssize_t size_show(struct device *dev, struct dev_dax *dev_dax = to_dev_dax(dev); unsigned long long size; - device_lock(dev); + guard(device)(dev); size = dev_dax_size(dev_dax); - device_unlock(dev); return sprintf(buf, "%llu\n", size); } @@ -1080,17 +1061,16 @@ static ssize_t size_store(struct device *dev, struct device_attribute *attr, return -EINVAL; } - device_lock(dax_region->dev); - if (!dax_region->dev->driver) { - device_unlock(dax_region->dev); + guard(device)(dax_region->dev); + if (!dax_region->dev->driver) return -ENXIO; - } - device_lock(dev); + + guard(device)(dev); rc = dev_dax_resize(dax_region, dev_dax, val); - device_unlock(dev); - device_unlock(dax_region->dev); + if (rc) + return rc; - return rc == 0 ? len : rc; + return len; } static DEVICE_ATTR_RW(size); @@ -1137,21 +1117,20 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr, if (rc) return rc; - rc = -ENXIO; - device_lock(dax_region->dev); - if (!dax_region->dev->driver) { - device_unlock(dax_region->dev); - return rc; - } - device_lock(dev); + guard(device)(dax_region->dev); + if (!dax_region->dev->driver) + return -ENXIO; + guard(device)(dev); to_alloc = range_len(&r); - if (alloc_is_aligned(dev_dax, to_alloc)) - rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc); - device_unlock(dev); - device_unlock(dax_region->dev); + if (!alloc_is_aligned(dev_dax, to_alloc)) + return -ENXIO; - return rc == 0 ? len : rc; + rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc); + if (rc) + return rc; + + return len; } static DEVICE_ATTR_WO(mapping); @@ -1196,27 +1175,23 @@ static ssize_t align_store(struct device *dev, struct device_attribute *attr, if (!dax_align_valid(val)) return -EINVAL; - device_lock(dax_region->dev); - if (!dax_region->dev->driver) { - device_unlock(dax_region->dev); + guard(device)(dax_region->dev); + if (!dax_region->dev->driver) return -ENXIO; - } - device_lock(dev); - if (dev->driver) { - rc = -EBUSY; - goto out_unlock; - } + guard(device)(dev); + if (dev->driver) + return -EBUSY; align_save = dev_dax->align; dev_dax->align = val; rc = dev_dax_validate_align(dev_dax); - if (rc) + if (rc) { dev_dax->align = align_save; -out_unlock: - device_unlock(dev); - device_unlock(dax_region->dev); - return rc == 0 ? len : rc; + return rc; + } + + return len; } static DEVICE_ATTR_RW(align); From patchwork Fri Dec 15 05:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 179036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9055914dys; Thu, 14 Dec 2023 21:27:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5IVQXLMoyfd45v1DADt2PwV/h85KPv1RwEP1svOcdKje32YCL4p2L+sp0M/3reaQDxw/w X-Received: by 2002:a17:906:51d1:b0:a22:fad4:f255 with SMTP id v17-20020a17090651d100b00a22fad4f255mr1812007ejk.104.1702618027651; Thu, 14 Dec 2023 21:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702618027; cv=none; d=google.com; s=arc-20160816; b=auzA0B7BApUXQUuBxCQJCcTZtO5G176dOicI5S8O+KG83dGbS2X0Yd+3UbSBUEAi82 VRBK2MZBOXmAI4CBF/d69y/y8TBjxKSHPqHAbwZZwr9zipzli88k3xJZdvPKu1jWtGli N6IJpLNr5KE0r5H6OYe5oWa8eje3+k9vBFzC9sNx+1+d6WTqgOD/KOAT2iN3QUk92IUi KRBc07fKg5vTaOwb5aXM0cnLIgzi3HkcGIZ0uCuuPZiwZeX77ilgJkqdh4mVT79cOof3 b4JnNwIYXKTwDnw8yiVSv6xuTLfKp/ajmU3TMu0rYR6/ReimoJEFcoKBEVSUq7PmigLG qqOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ICpmLRSWxW4h+Ok4MRUPEjX88+GqQOKKr/nSwj8Jvt8=; fh=sl/ePOXhMBHViO3TWdUhfhoSGyyi7lxtVvoNUwzQSs4=; b=VwYh37rQuBZkfiWdOhr9sKkfAPtS89Wm4MyAxpylbVN9/N3pE4Ge8GgDvIs6k9kZMT tX7GcaaWX1bsjLC0Q3tascJqubtk+5obts5jNPGVADts6Ck/5y7n2DR9y/HFRnzbzeJi vhx7xMAIXOWXLHEiDUhxQ02+dQMLbgZiNL5ETPSKvqYCV5HxOtG8VnvBOp0S4HEJjJFo STjCVQEOZT31D6i5FU1v4J1REUlzaw5ZIsMMDkARSlGKDaD7RrlADL9e2OQVBHzvxWbt kWbApcdSibg3RwRQzYiaoofuN5o3XKq/RLNOgkWdHYOzcE69W3y7KpKXlKK2tulVUk8i lDCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AhvUKw00; spf=pass (google.com: domain of linux-kernel+bounces-446-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-446-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k18-20020a1709060cb200b00a231003c247si1047239ejh.531.2023.12.14.21.27.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:27:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-446-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AhvUKw00; spf=pass (google.com: domain of linux-kernel+bounces-446-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-446-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 20A021F22A28 for ; Fri, 15 Dec 2023 05:27:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1716610952; Fri, 15 Dec 2023 05:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AhvUKw00" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 DC2556AA4; Fri, 15 Dec 2023 05:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702617940; x=1734153940; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=sNbGEdgrAJp/XDJyFdtJon3rtI5vNIQSMJsEoh64H1k=; b=AhvUKw00YT8ZDeded8UcRiz9Fm0qx2UbiOsxVwBE53rxIAvLLFQJR5LL gyI6FO6XTbwgvcLaHaWYkG/E1ChXUUGN7GXKnQy1xYnOrp8CT0PfMRfc7 7hk9ihFdDhNqHv1Hm2KMuQg5Yqee1snFbl2bqQOdKjNWacqEsF6un3o9b ATxDYghYgXutNmA8ndkUJAyAk9FC1n36wXEJCGubVfaYjxpruumSlFRfv yWEMoNYcs4ee2yVAOnYblM+5kBmvsAeqIF//EBHJQd16BX7H9aJeIyQeV mBoTy9ZQUH7yBF+Va5cKDnQAzA3feWUjV36r81M+qrupwarxhs5eVLu3f w==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461695031" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="461695031" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="808847946" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="808847946" Received: from mmtakalk-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.109.101]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:39 -0800 From: Vishal Verma Date: Thu, 14 Dec 2023 22:25:28 -0700 Subject: [PATCH v6 3/4] mm/memory_hotplug: export mhp_supports_memmap_on_memory() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231214-vv-dax_abi-v6-3-ad900d698438@intel.com> References: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> In-Reply-To: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org, Michal Hocko X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=4673; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=sNbGEdgrAJp/XDJyFdtJon3rtI5vNIQSMJsEoh64H1k=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnVj/270n4d1C7Pn6OllvEj6eOC3R8OBFpMDgs02furb V3h077XHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZjIaUVGhqvHbgn7n1PPSKt8 aNv1aHOVz+W7sd8qQ4V6SpzvsupvfMzwV6rjV/PTnz9mp3x8tmXRRvvOFYsvNPeVZ3jKPWjX1Zr qzQgA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785324401041262488 X-GMAIL-MSGID: 1785324401041262488 In preparation for adding sysfs ABI to toggle memmap_on_memory semantics for drivers adding memory, export the mhp_supports_memmap_on_memory() helper. This allows drivers to check if memmap_on_memory support is available before trying to request it, and display an appropriate message if it isn't available. As part of this, remove the size argument to this - with recent updates to allow memmap_on_memory for larger ranges, and the internal splitting of altmaps into respective memory blocks, the size argument is meaningless. Cc: Andrew Morton Cc: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Dan Williams Cc: Dave Jiang Cc: Dave Hansen Cc: Huang Ying Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Signed-off-by: Vishal Verma --- include/linux/memory_hotplug.h | 6 ++++++ mm/memory_hotplug.c | 17 ++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 7d2076583494..ebc9d528f00c 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -121,6 +121,7 @@ struct mhp_params { bool mhp_range_allowed(u64 start, u64 size, bool need_mapping); struct range mhp_get_pluggable_range(bool need_mapping); +bool mhp_supports_memmap_on_memory(void); /* * Zone resizing functions @@ -262,6 +263,11 @@ static inline bool movable_node_is_enabled(void) return false; } +static bool mhp_supports_memmap_on_memory(void) +{ + return false; +} + static inline void pgdat_kswapd_lock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {} diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 926e1cfb10e9..751664c519f7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1325,7 +1325,7 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) } #endif -static bool mhp_supports_memmap_on_memory(unsigned long size) +bool mhp_supports_memmap_on_memory(void) { unsigned long vmemmap_size = memory_block_memmap_size(); unsigned long memmap_pages = memory_block_memmap_on_memory_pages(); @@ -1334,17 +1334,11 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * Besides having arch support and the feature enabled at runtime, we * need a few more assumptions to hold true: * - * a) We span a single memory block: memory onlining/offlinin;g happens - * in memory block granularity. We don't want the vmemmap of online - * memory blocks to reside on offline memory blocks. In the future, - * we might want to support variable-sized memory blocks to make the - * feature more versatile. - * - * b) The vmemmap pages span complete PMDs: We don't want vmemmap code + * a) The vmemmap pages span complete PMDs: We don't want vmemmap code * to populate memory from the altmap for unrelated parts (i.e., * other memory blocks) * - * c) The vmemmap pages (and thereby the pages that will be exposed to + * b) The vmemmap pages (and thereby the pages that will be exposed to * the buddy) have to cover full pageblocks: memory onlining/offlining * code requires applicable ranges to be page-aligned, for example, to * set the migratetypes properly. @@ -1356,7 +1350,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * altmap as an alternative source of memory, and we do not exactly * populate a single PMD. */ - if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) + if (!mhp_memmap_on_memory()) return false; /* @@ -1379,6 +1373,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) return arch_supports_memmap_on_memory(vmemmap_size); } +EXPORT_SYMBOL_GPL(mhp_supports_memmap_on_memory); static void __ref remove_memory_blocks_and_altmaps(u64 start, u64 size) { @@ -1512,7 +1507,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) * Self hosted memmap array */ if ((mhp_flags & MHP_MEMMAP_ON_MEMORY) && - mhp_supports_memmap_on_memory(memory_block_size_bytes())) { + mhp_supports_memmap_on_memory()) { ret = create_altmaps_and_memory_blocks(nid, group, start, size); if (ret) goto error; From patchwork Fri Dec 15 05:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 179037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9055949dys; Thu, 14 Dec 2023 21:27:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEhnFm/n5LuGm0UrKWClDMLEEyh3EIBGsYXEui7wg7DMz9OEtDEngqJpUnzkKhH46wUVZ+ X-Received: by 2002:a17:902:6f16:b0:1d3:66ba:454d with SMTP id w22-20020a1709026f1600b001d366ba454dmr2317275plk.4.1702618036520; Thu, 14 Dec 2023 21:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702618036; cv=none; d=google.com; s=arc-20160816; b=fv1tt9t4wMSydd51toeW7hK6MdjaOHy7kGLnJdasYjQCfSMQz5+gtibK60kgtrdwMg cRF/plHgjuhiwbNBk+Fo2wX8+3jwtdovks7RnW83Dcbe+Y7w4z3n5Oy/vrykrZcE3AM5 cdAJ9UtELDDKbPa5j8bR6F1bOJHmu56iICMjmdnSdW+u2b3mr6o4JpFuUHY1QvBtAvas 3zTY/JDZ0Km8kIpn0/akdfNC+n/gi+XKmAjW6Wr3yMaYPYC/R4J/F/r5LsVXEg3uTPCZ kOQBJYgBYE79kK1LHuwl+sb6eABibVU06VEJD7EGPQBRcBndKjtp20FTgTbA/5id4+eq q6WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ypOKwW1hPaXDtU75GzRcGaliD9n4629vuU0d5YGt1I4=; fh=W5PgHD4oq/kXUq62l3dls1PwFvusEGE3FnZhfx8GmxI=; b=u25V6XtLqj7pelSSTGxt6y+cVY7/kMWu44KKskwzhEPscNQYVnX1zzkVWynuwNByan e3PUSvAZUJJgMPJV21Aqz3o6kFh3etfTdEByXmMJix0T+F8RnmrYBDmMmcqqzhGDWXvd 9vT0gWHeRIkgnBaL++F2OIAoa/WlbqtIF3M7ZAD/m6vMcB6vwkJG5zE/TLQotFm0u6R/ PMsVSdonjYQz+PYfSGeLsmdXwHSm3/b87aZDehhQvhlwuPdFkJNxOaYzJm2n+e97rTyp tFj4BDN2MM2XFYSaHejZJsDxXdrYgJ4V9C+lkOfqb2rAmajYI7dZMl035UUEw1vE6UXl Wn9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O15cn6OX; spf=pass (google.com: domain of linux-kernel+bounces-447-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-447-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c9-20020a170902d48900b001d3766085a1si1496511plg.564.2023.12.14.21.27.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:27:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-447-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O15cn6OX; spf=pass (google.com: domain of linux-kernel+bounces-447-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-447-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 64B75B223B9 for ; Fri, 15 Dec 2023 05:27:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C17B610A16; Fri, 15 Dec 2023 05:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="O15cn6OX" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 7D1056FC6; Fri, 15 Dec 2023 05:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702617941; x=1734153941; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=8AydkZIRYE6htCOriMTQ/LIKTv23UzbFF+2Jgw5CRZ8=; b=O15cn6OXNfftlH1/lrTND8psms4TDZQ6AZEHIMHNypaQESwqeDHK5PZk BSFQlBBWN2I1gSpftccfLAuAUw5wBqtXx6rXIAkPJRqQdscsrGhoqgc00 t1ycealMa8uf2QYkHq7/w5LdhLjdB9uDnnpBmnUTc1RdOktfnlAy9csSz /vbsHLmp3JX7XErycPdGdDhpoflGIy2xaIiPk+erDsNVNzX539ml4o7Nc sjaI1KV5kUpSftkR0vsaCnj4yiqqb2gTdSvAvdE16CGkg/kDI/NtN7PDu 3KVxkLuNn5lG/ruj4KuQUAnUOWqIgWcM4jlppeUK+Z4ZxBYmuvnxXgbq1 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461695041" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="461695041" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="808847952" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="808847952" Received: from mmtakalk-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.109.101]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 21:25:39 -0800 From: Vishal Verma Date: Thu, 14 Dec 2023 22:25:29 -0700 Subject: [PATCH v6 4/4] dax: add a sysfs knob to control memmap_on_memory behavior Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231214-vv-dax_abi-v6-4-ad900d698438@intel.com> References: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> In-Reply-To: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org, Li Zhijian , Jonathan Cameron X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=3850; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=8AydkZIRYE6htCOriMTQ/LIKTv23UzbFF+2Jgw5CRZ8=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnVjwPMrpyut8x1v9xyeMKEi/HFHefXVb0r+zd5yfV7o h28Z3iUO0pZGMS4GGTFFFn+7vnIeExuez5PYIIjzBxWJpAhDFycAjARkWpGhjNf+ITlduxj1Trv ej864P87z0kCPQrNscmyYadszWv/rWP47z0rq7qGh41zMU9LWP5txanfJ8q82v08OECBd+ldtwf VHAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785324410228966606 X-GMAIL-MSGID: 1785324410228966606 Add a sysfs knob for dax devices to control the memmap_on_memory setting if the dax device were to be hotplugged as system memory. The default memmap_on_memory setting for dax devices originating via pmem or hmem is set to 'false' - i.e. no memmap_on_memory semantics, to preserve legacy behavior. For dax devices via CXL, the default is on. The sysfs control allows the administrator to override the above defaults if needed. Cc: David Hildenbrand Cc: Dan Williams Cc: Dave Jiang Cc: Dave Hansen Cc: Huang Ying Tested-by: Li Zhijian Reviewed-by: Jonathan Cameron Reviewed-by: David Hildenbrand Signed-off-by: Vishal Verma Reviewed-by: "Huang, Ying" --- drivers/dax/bus.c | 36 +++++++++++++++++++++++++++++++++ Documentation/ABI/testing/sysfs-bus-dax | 17 ++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 6226de131d17..3622b3d1c0de 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1245,6 +1245,41 @@ static ssize_t numa_node_show(struct device *dev, } static DEVICE_ATTR_RO(numa_node); +static ssize_t memmap_on_memory_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dev_dax *dev_dax = to_dev_dax(dev); + + return sysfs_emit(buf, "%d\n", dev_dax->memmap_on_memory); +} + +static ssize_t memmap_on_memory_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct dev_dax *dev_dax = to_dev_dax(dev); + ssize_t rc; + bool val; + + rc = kstrtobool(buf, &val); + if (rc) + return rc; + + if (val == true && !mhp_supports_memmap_on_memory()) { + dev_dbg(dev, "memmap_on_memory is not available\n"); + return -EOPNOTSUPP; + } + + guard(device)(dev); + if (dev_dax->memmap_on_memory != val && dev->driver && + to_dax_drv(dev->driver)->type == DAXDRV_KMEM_TYPE) + return -EBUSY; + dev_dax->memmap_on_memory = val; + + return len; +} +static DEVICE_ATTR_RW(memmap_on_memory); + static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); @@ -1271,6 +1306,7 @@ static struct attribute *dev_dax_attributes[] = { &dev_attr_align.attr, &dev_attr_resource.attr, &dev_attr_numa_node.attr, + &dev_attr_memmap_on_memory.attr, NULL, }; diff --git a/Documentation/ABI/testing/sysfs-bus-dax b/Documentation/ABI/testing/sysfs-bus-dax index 6359f7bc9bf4..b34266bfae49 100644 --- a/Documentation/ABI/testing/sysfs-bus-dax +++ b/Documentation/ABI/testing/sysfs-bus-dax @@ -134,3 +134,20 @@ KernelVersion: v5.1 Contact: nvdimm@lists.linux.dev Description: (RO) The id attribute indicates the region id of a dax region. + +What: /sys/bus/dax/devices/daxX.Y/memmap_on_memory +Date: January, 2024 +KernelVersion: v6.8 +Contact: nvdimm@lists.linux.dev +Description: + (RW) Control the memmap_on_memory setting if the dax device + were to be hotplugged as system memory. This determines whether + the 'altmap' for the hotplugged memory will be placed on the + device being hotplugged (memmap_on_memory=1) or if it will be + placed on regular memory (memmap_on_memory=0). This attribute + must be set before the device is handed over to the 'kmem' + driver (i.e. hotplugged into system-ram). Additionally, this + depends on CONFIG_MHP_MEMMAP_ON_MEMORY, and a globally enabled + memmap_on_memory parameter for memory_hotplug. This is + typically set on the kernel command line - + memory_hotplug.memmap_on_memory set to 'true' or 'force'."