Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4531243rdb; Tue, 12 Dec 2023 02:06:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEgVqD0DSUSanLpx14DgmxrwTPtWWqkvwqc3ltRCkksIyr7CT6d1N7MMhEcudrXaLy3gCC X-Received: by 2002:a05:6a20:3942:b0:18f:97c:6163 with SMTP id r2-20020a056a20394200b0018f097c6163mr8498288pzg.96.1702375572760; Tue, 12 Dec 2023 02:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702375572; cv=none; d=google.com; s=arc-20160816; b=UsnKesQkx3DB8Ikodi43YyCQJMPTWQB2fIrN3lrYB4TPtikUxKpYKTU3IB6IkmA7kQ F97smzfrqRphhFz1HFuMfqWk35LALUKD/wGl/PJ2xH/F2eFA0BhjPWD9b99U2FxgFMSz ruPMiy0910UxzdMftZHuRYwUkz/NLacQ+TZsA6nraD+FxJJuE8eaWI0lnPxhr+GRqoL4 FdhEy284RcQmWNMEH09qnphbXNxILw1NWcPi3EA95AEguH+juDy7OJOAOgnI1PSbHAxa nE9VqoPfziaeZMyjWYTVbwwFvH/xWrUjIRttEczNsBKYfp4WYwNI/eL9eWkJ6Z3v5NEn lJ5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=MaFI2nLzy2BuURLvmJJteNjl3+hrowavzBk9ysSya2U=; fh=/W2eY8IUK9zmN+AyhDPD3fA5wKm0Bi/6x7bpQ/nvoBM=; b=yGqZhw8+Ouf7SE4R+W55UhpgceYvbxqWcN1RcA/Vt+qy5ZBA8LtE/rWPJRUU4i2lF3 REgvWGDELkfm7+bxv8pfD8nf8++b8Y9CVf9JOOLS2WhkYtAuJXb7LtNK4mhX58ZgXeWu qCI6ortA5AMeoLyo3IR1LYqG2tlGZ0rSvNfEClUcpHp95aUA4XvHPS5UzFLgbRGfbLQO pKC/xgUIfOpcftlfi78CIGQ96OFvyL/hLHrtKcmSdHPGKjmDCEH733e8XmYjsoGEeqVL oeSsmRAKJZ4UslmG0BX3sq7kFE8f6MVDWDOWeSsa46oH+cVj++8L/LOw/VT/FLfA+rCU QV5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WaXWekMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v29-20020a63481d000000b005bde6fae09asi7320005pga.135.2023.12.12.02.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 02:06:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WaXWekMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 288F480BAA86; Tue, 12 Dec 2023 02:06:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346144AbjLLKFy (ORCPT + 99 others); Tue, 12 Dec 2023 05:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjLLKFw (ORCPT ); Tue, 12 Dec 2023 05:05:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A55FD92 for ; Tue, 12 Dec 2023 02:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702375557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=MaFI2nLzy2BuURLvmJJteNjl3+hrowavzBk9ysSya2U=; b=WaXWekMIk/pi1sScJ7v+mw1TCO41ttqokUq2PcIjywEux9rg5HuqK+GHvM5ZsdNoey6a7l f+b9wTuOuteZnVdRP20fHp1KaawCtedLJBawV3MSFHPuFl9/zVUHWeE2mXTu2tujR6JOeL 186oQLUHio2VUZmHhq9TPbnmf209LpA= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-Zfu8SN73MDKF2UjRL58iog-1; Tue, 12 Dec 2023 05:05:56 -0500 X-MC-Unique: Zfu8SN73MDKF2UjRL58iog-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3334b472196so4525177f8f.1 for ; Tue, 12 Dec 2023 02:05:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702375555; x=1702980355; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MaFI2nLzy2BuURLvmJJteNjl3+hrowavzBk9ysSya2U=; b=WwvSSYdqS9RcdPz+7MH0esJuWKp6r34jpVQW+2osNoUZAno1AbF5h1afWwAW2Dn3Um NU9mprgBwXnq/RF7MEySNREz0ntcxu4CErLCDB1D838tfSHKtm/JRRU/cyWn0tk3U5XS TlTD2VxHKnNNH0egGTTvchZEI5D/zFqqDPgHEpLq4cgWrMowLjR24R3bjZz7XTjTLmKk udecjw8LKaeSp+xMOPFlbeGr9HDqXpq9azot1RhHudwrz5NrNoCRrjgvs2WYJVPYFJeP wEdMgQtpiq74cacl4tbCf19gSDDtbm6aVruYn6K/qagm76H5gdP0gCndMbqsg3llCb0z Bg1w== X-Gm-Message-State: AOJu0YycO63UHFjSTPYSHrHOl/3d0Ip3ce96+AGurifSYhwkNuddPGhi ToFKDIF/PkU8aCRUg2xgzk+srapGHvJAdzj/vZJoFsIE7QrFZtIxI+D+XJikOfOYDk0aWYy4Ofu cPwnfkgjjRVzCmBzdlVQNQIW7 X-Received: by 2002:a5d:620a:0:b0:333:3c28:767a with SMTP id y10-20020a5d620a000000b003333c28767amr2470370wru.46.1702375555456; Tue, 12 Dec 2023 02:05:55 -0800 (PST) X-Received: by 2002:a5d:620a:0:b0:333:3c28:767a with SMTP id y10-20020a5d620a000000b003333c28767amr2470357wru.46.1702375554983; Tue, 12 Dec 2023 02:05:54 -0800 (PST) Received: from ?IPV6:2003:cb:c74b:ca00:4ca2:ff2c:9092:f070? (p200300cbc74bca004ca2ff2c9092f070.dip0.t-ipconnect.de. [2003:cb:c74b:ca00:4ca2:ff2c:9092:f070]) by smtp.gmail.com with ESMTPSA id e18-20020a056000121200b00333404e9935sm10381362wrx.54.2023.12.12.02.05.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Dec 2023 02:05:54 -0800 (PST) Message-ID: <68582759-c74e-4bd8-b055-58eff81ef2e2@redhat.com> Date: Tue, 12 Dec 2023 11:05:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] dax: add a sysfs knob to control memmap_on_memory behavior Content-Language: en-US To: Vishal Verma , Dan Williams , Dave Jiang Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Dave Hansen , Huang Ying , Li Zhijian , Jonathan Cameron References: <20231211-vv-dax_abi-v3-0-acf6cc1bde9f@intel.com> <20231211-vv-dax_abi-v3-2-acf6cc1bde9f@intel.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKC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UFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231211-vv-dax_abi-v3-2-acf6cc1bde9f@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 02:06:10 -0800 (PST) On 11.12.23 23:52, Vishal Verma wrote: > 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 > --- > drivers/dax/bus.c | 47 +++++++++++++++++++++++++++++++++ > Documentation/ABI/testing/sysfs-bus-dax | 17 ++++++++++++ > 2 files changed, 64 insertions(+) > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > index 1ff1ab5fa105..2871e5188f0d 100644 > --- a/drivers/dax/bus.c > +++ b/drivers/dax/bus.c > @@ -1270,6 +1270,52 @@ 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 sprintf(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 device_driver *drv = dev->driver; > + struct dev_dax *dev_dax = to_dev_dax(dev); > + struct dax_region *dax_region = dev_dax->region; > + struct dax_device_driver *dax_drv = to_dax_drv(drv); > + ssize_t rc; > + bool val; > + > + rc = kstrtobool(buf, &val); > + if (rc) > + return rc; > + > + if (dev_dax->memmap_on_memory == val) > + return len; > + > + device_lock(dax_region->dev); > + if (!dax_region->dev->driver) { > + device_unlock(dax_region->dev); > + return -ENXIO; > + } > + > + if (dax_drv->type == DAXDRV_KMEM_TYPE) { > + device_unlock(dax_region->dev); > + return -EBUSY; > + } > + > + device_lock(dev); > + dev_dax->memmap_on_memory = val; > + device_unlock(dev); > + > + device_unlock(dax_region->dev); > + 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); > @@ -1296,6 +1342,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 a61a7b186017..b1fd8bf8a7de 100644 > --- a/Documentation/ABI/testing/sysfs-bus-dax > +++ b/Documentation/ABI/testing/sysfs-bus-dax > @@ -149,3 +149,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: October, 2023 > +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'." > Thinking about it, I wonder if we could disallow setting that property to "true" if the current configuration does not allow it. That is: 1) Removing the "size" parameter from mhp_supports_memmap_on_memory(), it doesn't make any sense anymore. 2) Exporting mhp_supports_memmap_on_memory() to modules. 3) When setting memmap_on_memory, check whether mhp_supports_memmap_on_memory() == true. Then, the user really gets an error when trying to set it to "true". -- Cheers, David / dhildenb