From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 A201334E762 for ; Thu, 9 Jul 2026 15:07:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783609625; cv=none; b=RvmrGeyooS74K5tC0Wl7Lm5+FG6LRUzevz4lJ+HgwSMRGFBSqg4XwHsOdocX5j9j8zgnCikcIpcYCr2KLBl098+6nL/lFTxGiDmv6XsKKJxHx5jcvFACRtXvE0xM1DVvB3hZ3dc//S3bA3rqRrIT3t5yUrTmKuqijXVoKu1frec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783609625; c=relaxed/simple; bh=/grVSRUciXotV+M5DyGJv/gSDKzJoMKn2myJZvg9YgU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RR2HJSmmvWnPuS2+7pBTGBzbCGls25S86N2WQyPyTeEA3b6Cu0heotlIrGJv/5HpyF3GkG8jAaofGnpxYMMsY/AZoYN5nCcRGhUtR7yRbENSADzHN9b9x5hQv+vlP5WF2tuPEFm1VXJHsOZsX9mTSb1XaD/++Va2qOX66PKCLxE= 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=KgZDfzEV; arc=none smtp.client-ip=209.85.160.171 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="KgZDfzEV" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-51c0c68aa31so13653371cf.3 for ; Thu, 09 Jul 2026 08:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783609622; x=1784214422; 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=LA4FqejTaFf1jVYUF/eNvlLLZJZ5tRpTNigHNeOPvho=; b=KgZDfzEVrSihwClIha5vLHr7gLsNnyeQqcYHGIdkMpi7tEj8SqpYCn0XECKw1bhxcX yNLWW0PW/Cd4/BjP8l8jOyjsK9N+8tKkeLG6FxKIuhJUmcOkmdmXeRV62p/NKrEHu+Iq K4spBhoXhSjSPGEvFM0J7Av9oNHz3OWaHpLozVega43cShCUdxyJ9C149A6Y4Vw8IuOO RVySdQslv7NpErUZrG9VzAUOmwrMD1lXcZpAGkrVglvRyT3OiW+6Ru93fHAU3KNjpPi4 GiwnWhDvUCl1sNL9HDBu3nKjD6bqZqcA4JnwHWfErw1u3UI+HnFjGVrin4t+4k2qV393 NfmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783609622; x=1784214422; 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=LA4FqejTaFf1jVYUF/eNvlLLZJZ5tRpTNigHNeOPvho=; b=HmjBHsbhYSMynmjdiqh0XzRQzstGaD7dnKoMpoVpD58Er2TeDVmwDleYm/0Fs7ZmfH KlqjKAWu6MevhPkhkqX2jdTrBLayzI9fjHVEoVMMrt99FPJ4KdzXZzji/VRPqj3TcSXF K4sb0jP0TWEOx7cyaRA09Xnzh+q7Mj+E699WPH7Kkmj5pRCaZWtbCKXDtCEemcaUo4+K 9g4xQf+bgYfnal3WV8J6S2I19WgRiRZQyi/ZxRwyYOZj88XROmTx6ayh1ZOPaUf1Qnbb qcM+yQ0F+jj4qI33gmA5P9iDNESIjstyxIqfCnVYUdMPKNqfF+nCTVztF+bOb892+1JU gisQ== X-Forwarded-Encrypted: i=1; AHgh+RpSwyzyTs3whww4xM1YR5ZHv+Re8M0VrZleOK6Vr8CA9EOG3zfudx/whEpeKApE1OUxyjAH2aFC94c7hOg=@vger.kernel.org X-Gm-Message-State: AOJu0Yxn2t0ffWsZyHQt+n8bpS7l8/g0jOIeE5XNMXDK6iVvHAoZVHrI lpAEZZUUQURhzXDP9dVI2kYqeXAPhiVeY+vupfdEqnmkdRK80nIlQdb3Wex718g9C1I= X-Gm-Gg: AfdE7cmts0dU1qkgJG57PVGwgwGhaC3JJzhlcV/0mCkbvhF2Dc3Wm4A82ysg2yApW1+ 0c17EjhvMnM9Rn7+3dMRxgC9dudN7EVdUUc1CC+Eoq9/0F9uIoG9mUsQr4mGwZpqKy06FzqDNUW XcEjA9CoSUnN0eOI0m7yK/uf3t7zYKFNF2jBiUWlLR9eLaVgEiQ4FA/yY5xVtF1hApLKAFoYgEZ AWDImNoAq6Z1Wz01CIqGFiUo8gOAM6NNYR0UtXFFN8z8vT0xeUZg8PMOjyetV3RbDj1MrV6axql IyUxyJ/Q3D8h4VS8WtXG+KixCZ00w5D3/ezzDcwBggYbUB+n+8vzE/50DJyDhlFlD2pZ21T9bgu 1Q3YL/w3LxOczVSrEFLpLfWzNwY1QQD5CB93viKXB2738YSOrDswq1h07//yB5BwF/oPYHss9my nfCmOktFRik/JGt4ASpk0sKc45EoprWehsKPcRDbwKrMSpUolEopkV+8anWAXb7zojKwv//NGw3 XE1bUQ= X-Received: by 2002:a05:622a:1791:b0:51c:7b12:5fee with SMTP id d75a77b69052e-51c8b40f651mr77711651cf.74.1783609622533; Thu, 09 Jul 2026 08:07:02 -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 d75a77b69052e-51c42038c4bsm160321251cf.31.2026.07.09.08.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 08:07:02 -0700 (PDT) Date: Thu, 9 Jul 2026 11:06:57 -0400 From: Gregory Price To: Richard Cheng 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, djbw@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 Subject: Re: [PATCH v6 06/10] mm/memory_hotplug: add offline_and_remove_memory_ranges() Message-ID: References: <20260630211842.2252800-1-gourry@gourry.net> <20260630211842.2252800-7-gourry@gourry.net> 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: On Thu, Jul 09, 2026 at 04:45:51PM +0800, Richard Cheng wrote: > On Tue, Jun 30, 2026 at 05:18:38PM +0800, Gregory Price wrote: > > +/** > > + * offline_and_remove_memory_ranges - offline and remove multiple memory ranges > > + * @ranges: array of physical address ranges to offline and remove > > + * @nr_ranges: number of entries in @ranges > > + * > > + * Offline and remove several memory ranges as one operation, serialized > > + * against other hotplug operations by a single lock_device_hotplug(). > > + * > > + * This offlines all ranges before removing any of them. If offlining any > > + * range fails, the entire process is reverted and nothing is removed. > > + * This provides a fully atomic semantic for unplugging an entire device. > > + * > > + * Each range must be memory-block aligned in start and size. > > + * > > + * Return: 0 on success, negative errno otherwise. On failure no range has > > + * been removed. > > + */ > > I think this can return 1, and it shouldn't. > device_offline() returns 1 when a block is already offline, and phase 1 passes that value through as-is. > > Easy to hit with patch 0, offline one memory block via memoryN/state, then write > "unplugged" to daxX.Y/state. The store returns 1, userspace treats it as a partial write of 1 byte, > and retries the write with the rest of the string. > > Maybe > """ > if (rc > 0) > rc = -EBUSY; > """ Oh weird, I thought I'd solved this problem at some point. I must have botched a rebase or something. Good catch. I'd originaly had some tests that race memoryN/state and dax/state, but I dropped them because it caused long testing cycles (mostly because i was testing force unplugging). Maybe I'll re-introduce some of these partial tests and just avoid the destructive ones. ~Gregory