From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A039532BF41 for ; Thu, 9 Jul 2026 23:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783638406; cv=none; b=CbJneF7NedGlvmWUXUE2wr6P2B+B9lqmPvAaaiiq0Rj4SeNQxo/sp/Qid4PCfQzyv/R1PNBvyF+zMoH94bFT/pgocHxk0pT2YUVPPylfPCICnYstQujOOylrCvbluytdzfFBffR6jCu8GAuPvFvJKXfvmqenG3LzgxOArh7gZYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783638406; c=relaxed/simple; bh=Nr20FWjG2NroNbXZwhjr1SjTV8yECc1KxfDUU9MIAqU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=haTm3ReCSIU9uNPBRyxVO5MyyNtktGgfL49akK3D6NMYT5ElvYxyx6p8xxs8gzQR0QzBDz+cjb66+GjNN8Zm2tdiSMUc6/aGVpV5o89BQRZiabl89kTYLFlM8RDWgp0H1rWsQpDY73ATbiM/wyjjtbgnSj/U3lE0GDBH+ccpGAI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=QFPJ0QaM; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="QFPJ0QaM" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-92e50979c71so25227085a.3 for ; Thu, 09 Jul 2026 16:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783638404; x=1784243204; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=G+I1Kh+neFzTKmOmQym2AfGZpWjdwKJKu5WX9LjuS6A=; b=QFPJ0QaM+jKDmbawT46PNA7NSUWM3GHu5Dt3+ThjlsbAtweovklcUWNS4npkS1zU6J Gb9vQ3RDvclrvCUwaEFG0UjsnsjtM0WQFNctTffzLQkfPRR1uqhH2hsnphY+kygwGSEV 02KNN+Skz5mc6WxDH3IxsRCEzMB5M5KCFfwZuwIF6yXkaAdEnAe4hOYn4PZjJY41Lg3B yddNhJMmqP3KRURfQPiJXP5FpTH6MjbU4nmpgKJEnR9h0BzN9I07T35+zWly+Wu+UQW7 Uk7ViFJk6wdA8Gi0TRDBp+9MaVtNAs0qlSUbg0QwD+zLp40l0HQ0eRXLRHzXaJ02LTOl dhnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783638404; x=1784243204; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=G+I1Kh+neFzTKmOmQym2AfGZpWjdwKJKu5WX9LjuS6A=; b=gMy0s5uMD2iGVgD6XjBRKGN+5p3+s8I4o6JZJLKiGPVeSvAmuS5QBwmvV7IFV92dgW SxZW5OHczsbCQQMS0QTs+sEZFpzyhO2EmrQ4VmOM7KPh5i66pjIdCxQQMjrM26mZC9tE wrG1pDML15SGpZuDbDPVcEPT5ZRN8qBYcPamhSmSxyhpjPdKPKqFTGMtohHRW0vrDQFC ckhqejctzDNqt0b77dO4Ov/wF2LkAqEavbMw36tNDRQsSPeVlysa4kPNwmeZOKEaQn9X ioSKIlkuhzmoylbt0WjRK6l2UceuxWulQwkDuB4dwYx+o9DTXAQBCUuMijib6IH+jxZT gNng== X-Forwarded-Encrypted: i=1; AHgh+RoxhUnuO4Vm3fYXT+Je8Q7lJHekT+6iNazMLI/KN8T+JQmh/NqlBbVozFv0Ov1GIw+GXleQ9RigKpdMxVA=@vger.kernel.org X-Gm-Message-State: AOJu0YzOwiHZ+5LG2CNKTwHCaRc+NUGhNW7sV91ND5vktMH3vtBegXnk TCuBF8AjxFPFxXKPwNTjRhiHTfQBwtXew1fQ9X+2R3rK1B41RFDrKGU1GnvX0Mxykyw= X-Gm-Gg: AfdE7cn5jjkznHOvVxPEQQtLlL41KfICKIj6lT2ctkbCxxPZ7oKRUDteS21PYigO8OP rz8SrnMg/3xv23HA6p0j8jJv53P+dt+w3S5PP6Wg6fkjHgQSNIUpfm+sLARlw0+tHn3xE8ArcQX wom3crOy/N5ozkGgu4LokZYjAWVzUQMwggzzfVhBTW3ViqBi6zitjnAvmUbHLZQuxo42ggyG1ll q5pEtr/OOtcFz1Rv1czH240kgaeEPADfSzr0jv0bhd35aNMJxrAS5NLEiHp8t16E0r7Eru41Is+ ATqCip8O5YkkteeWMJov/uiEAMgEEnNRtBq1PIJrJkCtLME4YkGkXPGeaHzHe+JY70JDRouyLfi EgKkf04sS8q2A4/rZ36ycM64O1LuBkJ7c0MMFVzg/YPFuIJwY2osjxg5S0CrFZHoTvLe4jkhRtg y6/90n8nqXz1GBMH6wx7LCMoT1PeveL8XUHTXy1bxbEImOC0WzePJdE98IBZ6a8p2L95Pe X-Received: by 2002:a05:620a:31aa:b0:92e:7db8:1e86 with SMTP id af79cd13be357-92ecf6aa487mr1099339185a.58.1783638403562; Thu, 09 Jul 2026 16:06:43 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92ee5b4b1bbsm59189185a.2.2026.07.09.16.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 16:06:42 -0700 (PDT) Date: Thu, 9 Jul 2026 19:06:38 -0400 From: Gregory Price To: "Dan Williams (nvidia)" Cc: linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, driver-core@lists.linux.dev, linux-kselftest@vger.kernel.org, kernel-team@meta.com, david@kernel.org, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, alison.schofield@intel.com, akpm@linux-foundation.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, shuah@kernel.org, iweiny@kernel.org, Smita.KoralahalliChannabasappa@amd.com, apopple@nvidia.com, Hannes Reinecke Subject: Re: [PATCH v6 09/10] dax/kmem: add sysfs interface for atomic whole-device hotplug Message-ID: References: <20260630211842.2252800-1-gourry@gourry.net> <20260630211842.2252800-10-gourry@gourry.net> <6a502267b17cc_3b7ee51008f@djbw-dev.notmuch> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6a502267b17cc_3b7ee51008f@djbw-dev.notmuch> On Thu, Jul 09, 2026 at 03:36:23PM -0700, Dan Williams (nvidia) wrote: > Gregory Price wrote: > > + ranges = kmalloc_array(dev_dax->nr_range, sizeof(*ranges), GFP_KERNEL); > > The new hotness is: > > ranges = kmalloc_objs(*ranges, dev_dax->nr_range); > ack. > > +static ssize_t state_show(struct device *dev, > > + struct device_attribute *attr, char *buf) > > +{ > > + struct dax_kmem_data *data = dev_get_drvdata(dev); > > + const char *state_str; > > + > > + if (!data) > > + return -ENXIO; > > Cannot happen with a dev_group attribute. If probe succeeds then drvdata > is present. If probe fails, attribute never appears. > > When unplugging, dev_groups are unregistered before drvdata is cleared. > Ah good to know. I am always paranoid, but i'll drop. > > + > > + if (data->state == DAX_KMEM_UNPLUGGED) > > + state_str = "unplugged"; > > + else > > + state_str = mhp_online_type_to_str(data->state); > > + > > + return sysfs_emit(buf, "%s\n", state_str ?: "unknown"); > > So the "unknown" case does not need to be here. > mhp_online_type_to_str can technically return NULL, seems better to not just let a NULL dereference sit latent even if we can visually tell it can't happen today? > > + /* Always create blocks for backward compatibility, even if offline */ > > Unless maybe a driver knows better and wants to preclude the possibility > of legacy per-block hotplug policy firing? I.e. driver asks for dax_kmem > to start in the unplugged mode per my "should DAX_KMEM_UNPLUGGED be a > online_type with a different sentinel". > I suppose I can put DAX_KMEM_UNPLUGGED in the header and allow this. That seems reasonable, and makes sense why to differentiate DEFAULT/UNPLUGGED. ack. > > + rc = device_create_file(dev, &dev_attr_state); > > + if (rc) > > + dev_warn(dev, "failed to create state sysfs entry\n"); > > Always prefer statically declared attributes. In this case an attribute > that only appears while the driver is attached would be something like: > ack. > > - success = dax_kmem_do_hotremove(dev_dax, data); > > - if (success < dev_dax->nr_range) { > > - dev_err(dev, "Hotplug regions stuck online until reboot\n"); > > + if (dax_kmem_state_is_online(data->state)) { > > + dev_warn(dev, "Hotplug regions stuck online until reboot\n"); > > I like that the BUG() is avoided, but I think these should stay > dev_err() given the severity. > I had to go back to calling remove_memory() by default given different feedback, but I think if anything I will just modify the BUG() to a WARN() and call it a day. ack on dev_err(). > > + struct device *dev = &dev_dax->dev; > > + > > + device_remove_file(dev, &dev_attr_state); > > + > > One less cleanup to do if the attribute is registered statically. > Attributes are shutdown prior to this point. > ack. ~Gregory