Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2272903rdb; Fri, 8 Dec 2023 03:37:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiVEEvt4+f0CMPW9l4dMfJk6YIsnF+SgnAeIGzbN9Ztd/HcfHRK2gkJcduyKw4Gdro1VUE X-Received: by 2002:a17:902:e5c5:b0:1d0:6ffd:e2b8 with SMTP id u5-20020a170902e5c500b001d06ffde2b8mr4039913plf.82.1702035434272; Fri, 08 Dec 2023 03:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702035434; cv=none; d=google.com; s=arc-20160816; b=ScxVGvydY78/Bx/xRGmoZKXpoL+QRw4XP+zAAVBcaq6Duou1ktJVWvNp23trrYrdxh D6XpQyH1dVb7GN3hMiWI1y0sP6XcZG683tSWZdGZpPi6FSUpiG0pMcXSq/He7UgDQZeG 1YED18ViPNWJN8LEsPo83t6xhPToyg8/xEM5+assrO8txnqtZlNwVHimZJNuZaij/llc IB86wF6Fv6vJHN15uzYPp1Uph5FCjWoTknjaLNZ7TRp9n6gCbWm2ghdlPrC8JvSu6Heb 4M/3jNF/vGiJlZsCAtNB9C062I1jYg78AKLDQKa0/yHrTNIellQPXw5tHOBgenaTNdGU s5IA== 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=7iZNobHl/GPobGa2I6qixx18BC281Bjl3vJdU1mmkuQ=; fh=2pyC5Wn9pvpdegS6njMoqx8KArBXOpJ+0djfCw+NoWk=; b=neI3xalTXzHfcp1rBaEdIDUX9HhSda5NciekDCEj8ou5FTS1CrVVuVdH+m3n2rwEMZ ocPyL/KdZKqy0+6wHOqsIIX/H7CIgi0elQRchDx78phZOHsqexvawreZ1HpAR5oWIvn7 jjDBhXtXPnC3G+F8pH0wff4bLEkVJkafmhaI68t29DpLPFHWkTTs4H2H//euj4oC0vXF IUhRiRdWbQhwXLgmva18BlB+c/p+pF6AI/I7rtRslQvWC2rwFiHebPz5dWFV3LtPCy0F J+lKiZDiKm+84G92DRtvjzM8Hni6zZTSaxWuy3tf9e7+mnhRGWG/lsbYCuoD4hSwLht8 iPvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M8isj7Gz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t18-20020a1709028c9200b001cf677b6c20si1418151plo.594.2023.12.08.03.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 03:37:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M8isj7Gz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 133E08087E12; Fri, 8 Dec 2023 03:37:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573595AbjLHLgy (ORCPT + 99 others); Fri, 8 Dec 2023 06:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbjLHLgx (ORCPT ); Fri, 8 Dec 2023 06:36:53 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C077171D for ; Fri, 8 Dec 2023 03:36:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702035418; 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=7iZNobHl/GPobGa2I6qixx18BC281Bjl3vJdU1mmkuQ=; b=M8isj7Gzmk6RnET9OXHO43zLSQApDTC6e9x/9AtxGw432CO83hkgBIL2DCZ8BZhHSosD+G Z6YPZZm1/Rxm4TjQbn0Uakytrs+/gwlXV8WOhjNLb4hpUgrL+hUuusiUfXTuJOc3aEw7T/ hgKCXpt19JcxgZ8MGrCD84TzSRls0vg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-laGh8A2tPfWEpD2LuTM97A-1; Fri, 08 Dec 2023 06:36:57 -0500 X-MC-Unique: laGh8A2tPfWEpD2LuTM97A-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33608afb161so663486f8f.0 for ; Fri, 08 Dec 2023 03:36:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702035415; x=1702640215; 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=7iZNobHl/GPobGa2I6qixx18BC281Bjl3vJdU1mmkuQ=; b=GPnt2ddbqU1fMWgR+fLtVCd/7xGn9va9Xy43A/qzAJHDxH55bVR0Z9xzuqkIS27T4d wPXr0N3w2vtekpilSMjhMx/FnBDJWeVa2C5KxGuqM9DwvBzvUMjztZvautGRvUPWrA3E ZzIf66tktEHh4gI0zZwn4ALpWkeWou5vlBUbYyXTHvBIGq2b3IRiKpOaY+9muh1HtXT2 2NWQm3EePruWHjX0ooLhffTY/K9cdS71npIvhqHbi32r23rLT4+EE/05bL5ADTDusOJV fDGyXCENSxZqXSxy9wY/TiT3vhfcV5ToiZ/SEKI297lPvoIiebAqn4SIjx8fDx+i9rca DaxQ== X-Gm-Message-State: AOJu0YwapGTghgm+d0HCkxnVoMEJEcOyF0cahX5kGfzd1xHPwP6R8scb jcU0+nOY2w1Vm3oLmGR87WfpKS3MQJAiz4C+hMtV1W+jvdyQIIKUnViiKZ0ifSOvDH/ymT0Z/72 rJqOy1R3/bkDUuw8Xwi4iAFwL X-Received: by 2002:a05:600c:54f1:b0:40b:5e59:ccd4 with SMTP id jb17-20020a05600c54f100b0040b5e59ccd4mr2455930wmb.181.1702035415749; Fri, 08 Dec 2023 03:36:55 -0800 (PST) X-Received: by 2002:a05:600c:54f1:b0:40b:5e59:ccd4 with SMTP id jb17-20020a05600c54f100b0040b5e59ccd4mr2455915wmb.181.1702035415310; Fri, 08 Dec 2023 03:36:55 -0800 (PST) Received: from ?IPV6:2003:cb:c724:2100:3826:4f41:d72c:dc1b? (p200300cbc724210038264f41d72cdc1b.dip0.t-ipconnect.de. [2003:cb:c724:2100:3826:4f41:d72c:dc1b]) by smtp.gmail.com with ESMTPSA id m29-20020a05600c3b1d00b0040b3515cdf8sm2605930wms.7.2023.12.08.03.36.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Dec 2023 03:36:54 -0800 (PST) Message-ID: Date: Fri, 8 Dec 2023 12:36:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] dax: add a sysfs knob to control memmap_on_memory behavior Content-Language: en-US To: Vishal Verma , Dave Jiang Cc: Dan Williams , linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Dave Hansen , Huang Ying , Jonathan Cameron References: <20231206-vv-dax_abi-v2-0-f4f4f2336d08@intel.com> <20231206-vv-dax_abi-v2-2-f4f4f2336d08@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 ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh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LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231206-vv-dax_abi-v2-2-f4f4f2336d08@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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 08 Dec 2023 03:37:11 -0800 (PST) On 07.12.23 05:36, 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 > Reviewed-by: Jonathan Cameron > Reviewed-by: David Hildenbrand > Signed-off-by: Vishal Verma > --- > drivers/dax/bus.c | 40 +++++++++++++++++++++++++++++++++ > Documentation/ABI/testing/sysfs-bus-dax | 13 +++++++++++ > 2 files changed, 53 insertions(+) > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > index 1ff1ab5fa105..11abb57cc031 100644 > --- a/drivers/dax/bus.c > +++ b/drivers/dax/bus.c > @@ -1270,6 +1270,45 @@ 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 dev_dax *dev_dax = to_dev_dax(dev); > + struct dax_region *dax_region = dev_dax->region; > + 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; > + } > + > + device_lock(dev); > + dev_dax->memmap_on_memory = val; > + device_unlock(dev); > + > + device_unlock(dax_region->dev); > + return rc == 0 ? len : rc; > +} > +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 +1335,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..bb063a004e41 100644 > --- a/Documentation/ABI/testing/sysfs-bus-dax > +++ b/Documentation/ABI/testing/sysfs-bus-dax > @@ -149,3 +149,16 @@ 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). > Should we note the dependency on other factors as given in mhp_supports_memmap_on_memory(), especially, the system-wide setting and some weird kernel configurations? -- Cheers, David / dhildenb