From patchwork Fri Dec 15 05:25:25 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: 18097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9055326dys; Thu, 14 Dec 2023 21:26:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRzosw6aN1pjuchJbYCvBtVC/W9/FZc+mD3r9LQRO4mcRCinz3LqscTw85wnTc+3Sfv0TG X-Received: by 2002:a17:902:ec8a:b0:1d0:d18c:bc5a with SMTP id x10-20020a170902ec8a00b001d0d18cbc5amr13668664plg.121.1702617984829; Thu, 14 Dec 2023 21:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702617984; cv=none; d=google.com; s=arc-20160816; b=BBAhX4qY8XILi6HwLeXamUXPYz4RP8IBuoEyXHFuRyI/ok9OO5VJEytwcM8JKBE+Rj H9CwZH+63apXCS2tR9orrDlXRcDxWumZMSjkJP0EYZyAF31yINbgwg7kuhFM600idq+r 9kx0OYyc626qFBgs3PnJjQd96OyhhqVVHxbnUd577Russ7Ayy2K5AyAmKIQZGOTA8lny mhhuE0E/pHRTOkJmT52VMKt6Gnu2XOt5ripZi/HYv4womqqU4saYh2Ba2/gdpPPI8o0k 82p23MhdkJSQRPcod8rmk0qWFRnjVGtin4v1E0a2ehiXFMb2gO7uLkz5kggZnyEJmpLt Nvig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=EwdyGspY/MIAegoUUqf3JS5+9mXPB7XCF5YLzbu5QBs=; fh=oxUuK9ZsYNxwohTvy08JyvFuBZrHqMTKUC+iv2daseU=; b=D5yYo5g6OIMcmsFpD7XnuJo7LRFm6cbenrScTfH4SMZNYDEVkBOn1tyLDacYrsXZM8 fhCLe5q7aCRgoLvvFmEeSa2wkSwcWpgYTj+r8LFNgW65p4GiT+QTTIpQ6FF7xolrPpit FaLrND63LxypP8k4tRHDJCky+t0fVQLZ71111vjYX0SfPMMuf+AjKgLbvr1VJ6fQVHx/ 9B9IqIfCZv/hUnxyncjaqTe1vQ4Jt1otLwr+ThAkdkaW2soUjiEaCbCMmm/I0Dl8MXty E7cCnbXcyjm4giLTjc3lKUVGuVzgqeauqvLh4JTLpU7+SkBHLm+13UxXLXHcpNAE+tcD fIyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CIVEIeHH; spf=pass (google.com: domain of linux-kernel+bounces-443-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-443-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 h6-20020a170902704600b001d33c7ff07dsi5347321plt.67.2023.12.14.21.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:26:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-443-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=CIVEIeHH; spf=pass (google.com: domain of linux-kernel+bounces-443-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-443-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 92737284397 for ; Fri, 15 Dec 2023 05:26:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B6A7D2F1; 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="CIVEIeHH" 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 D972D569C; Fri, 15 Dec 2023 05:25:37 +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=1702617937; x=1734153937; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=gpIMG98kSfTR7IkA5YlRDrASpRxzVoLtmbllKBAG/Uo=; b=CIVEIeHHUjlmGEACu7ueGXwlbOVAvx1pIDe5lI+Uxs6UGTUPQ6TAPcHV C3GO1imcmlhDHGAhzodvmK7LLI50MHYC3Gzb184Z7/Qbwf0dxTEx/cIx+ tY1j0qLDK7zdqPhmsumq9Xg8RxTDMoEpwM4fyCjTaRoBqQQ1aht7cZd6M hrDGyZk4AMguFBX9tWkdcq/v9pPHtfmHSVfTHO9lah8Aq+jAuylK7V2WC t/vAmsTOSCiTLZPRtAvCYFgIG2E9D1R6ytIrbTOHc6ZAzgwtILaqO3KcW kRmEf0VtQBZPVlTo0HzjQdTPY15Nfcdw85y5YmtK/EMp2qcc1gOq8Yk4l A==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461695008" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="461695008" 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:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="808847923" X-IronPort-AV: E=Sophos;i="6.04,277,1695711600"; d="scan'208";a="808847923" 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:36 -0800 From: Vishal Verma Subject: [PATCH v6 0/4] Add DAX ABI for memmap_on_memory Date: Thu, 14 Dec 2023 22:25:25 -0700 Message-Id: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAEXje2UC/3XMTWrDMBCG4asErasyM/qzs+o9SgmSLDWC1i52E AnBd+8k3ciGMqtv4HnvYklzSYs4Hu5iTrUsZRp52JeDiGc/fiZZBt6CgBQCGVmrHPz15EOR6Dx hH7UFZwWDnznlcn3G3j94n8tymebbs13x8f3LENg2U1GC1E6n0HWJAONbGS/p6zVO3+KRqfQ/J aZZ85FSdoBuT1VDETdUMfUx2xgxDKnPe6pbShuqmaIy6EyXIfa0p6alekMNU5VdALC9haBbuq7 rL8jHlC+QAQAA 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 , Michal Hocko , Li Zhijian , Jonathan Cameron X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=4201; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=gpIMG98kSfTR7IkA5YlRDrASpRxzVoLtmbllKBAG/Uo=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnVj72DBQy7+sMEDkbc+rzgzleWNY1mWxuk89a8jnoaV PSzoedXRykLgxgXg6yYIsvfPR8Zj8ltz+cJTHCEmcPKBDKEgYtTACZSwcXIcGXl8Xs8j+yjThxc Jbroe5bpd089t8czdrTOkznRxMi4Sonhv2sN97OFe/XlLrqbdk0091qxU+vMhicVbluO37/4K2u DKR8A X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785324355892849970 X-GMAIL-MSGID: 1785324355892849970 The DAX drivers were missing sysfs ABI documentation entirely. Add this missing documentation for the sysfs ABI for DAX regions and Dax devices in patch 1. Switch to guard(device) semantics for Scope Based Resource Management for device_{lock,unlock} flows in drivers/dax/bus.c in patch 2. Export mhp_supports_memmap_on_memory() in patch 3. Add a new ABI for toggling memmap_on_memory semantics in patch 4. The missing ABI was spotted in [1], this series is a split of the new ABI additions behind the initial documentation creation. [1]: https://lore.kernel.org/linux-cxl/651f27b728fef_ae7e7294b3@dwillia2-xfh.jf.intel.com.notmuch/ --- This series depends on [2] which adds the definition for guard(device). [2]: https://lore.kernel.org/r/170250854466.1522182.17555361077409628655.stgit@dwillia2-xfh.jf.intel.com --- Other Logistics - Andrew, would you prefer patch 3 to go through mm? Or through the dax tree with an mm ack? The remaining patches are all contained to dax, but do depend on the memmap_on_memory set that is currently in mm-stable. --- Changes in v6: - Use sysfs_emit() in memmap_on_memory_show() (Greg) - Change the ABI documentation date for memmap_on_memory to January 2024 as that's likely when the 6.8 merge window will fall (Greg) - Fix dev->driver check (Ying) - Link to v5: https://lore.kernel.org/r/20231214-vv-dax_abi-v5-0-3f7b006960b4@intel.com Changes in v5: - Export and check mhp_supports_memmap_on_memory() in the DAX sysfs ABI (David) - Obtain dax_drv under the device lock (Ying) - Check dax_drv for NULL before dereferencing it (Ying) - Clean up some repetition in sysfs-bus-dax documentation entries (Jonathan) - A few additional cleanups enabled by guard(device) (Jonathan) - Drop the DEFINE_GUARD() part of patch 2, add dependency on Dan's patch above so it can be backported / applied separately (Jonathan, Dan) - Link to v4: https://lore.kernel.org/r/20231212-vv-dax_abi-v4-0-1351758f0c92@intel.com Changes in v4: - Hold the device lock when checking if the dax_dev is bound to kmem (Ying, Dan) - Remove dax region checks (and locks) as they were unnecessary. - Introduce guard(device) for device lock/unlock (Dan) - Convert the rest of drivers/dax/bus.c to guard(device) - Link to v3: https://lore.kernel.org/r/20231211-vv-dax_abi-v3-0-acf6cc1bde9f@intel.com Changes in v3: - Fix typo in ABI docs (Zhijian Li) - Add kernel config and module parameter dependencies to the ABI docs entry (David Hildenbrand) - Ensure kmem isn't active when setting the sysfs attribute (Ying Huang) - Simplify returning from memmap_on_memory_store() - Link to v2: https://lore.kernel.org/r/20231206-vv-dax_abi-v2-0-f4f4f2336d08@intel.com Changes in v2: - Fix CC lists, patch 1/2 didn't get sent correctly in v1 - Link to v1: https://lore.kernel.org/r/20231206-vv-dax_abi-v1-0-474eb88e201c@intel.com Cc: Cc: Cc: Cc: David Hildenbrand Cc: Dave Hansen Cc: Huang Ying Cc: Greg Kroah-Hartman Cc: To: Dan Williams To: Vishal Verma To: Dave Jiang To: Andrew Morton To: Oscar Salvador --- Vishal Verma (4): Documentatiion/ABI: Add ABI documentation for sys-bus-dax dax/bus: Use guard(device) in sysfs attribute helpers mm/memory_hotplug: export mhp_supports_memmap_on_memory() dax: add a sysfs knob to control memmap_on_memory behavior include/linux/memory_hotplug.h | 6 ++ drivers/dax/bus.c | 179 +++++++++++++++++--------------- mm/memory_hotplug.c | 17 ++- Documentation/ABI/testing/sysfs-bus-dax | 153 +++++++++++++++++++++++++++ 4 files changed, 260 insertions(+), 95 deletions(-) --- base-commit: a6e0c2ca980d75d5ac6b2902c5c0028eaf094db3 change-id: 20231025-vv-dax_abi-17a219c46076 Best regards,