From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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 EBB4D35DA42 for ; Thu, 9 Jul 2026 17:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783617325; cv=none; b=ogX9ON765wOmbnSNywKbKIm8sxUFlGkrnJIHa+0StDQFEbN7DpAu0Ool83zQTQXlXeyIJezYunvPZScy7tySqf7BQpbkr6IfquNSTKI6U5CO9y6Qq3VI9vky6iPyecrml5U20O7cridk2UdxPBaEp1hT3V0REdxZi8c8DVJA9DQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783617325; c=relaxed/simple; bh=SzROYG8BwD/EB/+MUjQ4u1vhoaHs3/zZwllWfULF+qU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GU6UXce7BIR8O+P2lnuH1ru6I9Hpf/98mhtFPtXBIWOH+8njDKOCMzhmRMIJEgDF7lTRgTgaCnkQH7b2DmQDoVtCE7h8h+cUmwNr2JXGHYlEVCAiWaKLMyltkWWXNscr4zhR0066hr2jYyDVRx0RiIFmuRdggccK9wL0WZ4LtKc= 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=gk0zhMxP; arc=none smtp.client-ip=209.85.219.44 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="gk0zhMxP" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-8ef1dc934d1so1159826d6.0 for ; Thu, 09 Jul 2026 10:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783617323; x=1784222123; 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=46UkRwT/i/djJx+KopbYZyKUrVPhRVpwIJdu7TzJpII=; b=gk0zhMxPCwdMeia9k1VETsBkdLdlSUiHgtr/lxI34cIdfLJu788hSwNC4UXQj5RHLF mex7yejvsPB2SSYb0a4ATL4mvLDHXVUcofAXP/G3aV+/e0HzaKcNf7cLVkkR85oNiD9m LoDWnj2LMAt7utzVlJ+XOrCTJtE7qaFqyJFxZygEzxhwSHJrCxDozHyHA1XvlQH+Jrbc imd7n4XXsQhloWf3R6EbXswShRm0e35oZVkp68wjNPOA5N6uqxNHp9O3nOq0N97Y+El4 7JS46cJLFNDyaPU2IWeXp0FUfg5eqh6HlWZMjjHIIOI/dAnwK60yX0GXfS4seLtNgcRL L6tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783617323; x=1784222123; 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=46UkRwT/i/djJx+KopbYZyKUrVPhRVpwIJdu7TzJpII=; b=GEBQSs5wyWrmWHdubIDFJoE7NWWZWIEzb+2Gwr8cYyyvg8Y62xEzqHStFx9HardAjZ nmlFlPOIgwUyLM640Nkk406Z2xHzouoB5DEGLMk/JX75Ntjdp7dsZPa/RB+aL/XPczlp oqeIumeXaex9joTD2Zy7Vboisjgi6Ahm+HevNiYYLk+zvPAynYvxYht2m/qkcYUZnlMm kPkuwt0h6aiGFpKuM7+h3N1zkv+4WwpQiQxcyUoZqSV27q0LtCiO/D0jjnEpSXrjp/lz 2ke9FCrcKjZMRAjCbdxqbTDzDEKp/zOpkMKLrEVlv/wzbHzRnGsmh6BuFEgZsvuNj75Y vUOw== X-Forwarded-Encrypted: i=1; AHgh+RpKpBXvi/qHeobOqFC46wvGAF9Prq4Mfbrgig+7nD23rB2I2kh6Qb+SjUmCmgYtVcx/mrjzeEOdvOHqiH0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6vTmnvCU8Y/HZJEASjaJAzROl67Q0kfbFZY7yWBo0goA/WX8n 1GumW2Qellzlr67EaE3bG4nco2qhIsprvIEio+NbmRFaud8GA+RpL7aPgASnYoge098= X-Gm-Gg: AfdE7clBpWXHQF+41O3u+uoBWoh8J+2dzTNCx4BDIQtQA0KEZfUXyNlpsvMt/ilmfoi Eo18C7TsjiPEv7RAC+clGXBZwXccPFGaMGiqc1FeTJraci+grOHp7eGYdTeiqAw24RJRtcgo0DD IKdBd4/5G2XP++hdYTl6fpu2fcwFWwJbrmdAJSeCVPX+htyCqznTSm9256PKA6JKA+O6XqYX2jO NpPbyNi1/8h7spyOvF4R9ErdQDd2osEyR2aoeyje9n9wsvkHr8DYjKUxth1OURs45G2oqlhG3/3 aReXCBdNMrOwdPXezo08bPOiLYlCmvBygX+yv8Oxprwfgf+lBgmuUCB5qo6gNHUpLRkXGDOX5R4 JL1pRtnbuyY1dvdJ3s5Hd7mgbts1PbEg/TtHXBqz1o3nD3U+VNxpI5kQDC0tI/iGID/vaau/h1b f9Pb/uExtzlqmxMDCLALwTUkyBO+asYHEWQ5+nyRFJL0QFEVAqwi8eYeNBBYL999Q+A1W5 X-Received: by 2002:a05:6214:6014:b0:8e9:f45f:107b with SMTP id 6a1803df08f44-90242143c3amr1641696d6.34.1783617322803; Thu, 09 Jul 2026 10:15:22 -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 6a1803df08f44-8ffd7c1d8fcsm22085656d6.25.2026.07.09.10.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:15:22 -0700 (PDT) Date: Thu, 9 Jul 2026 13:15:17 -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. > I just realized try_offline_memory_block() already clamps the value to 0 static int try_offline_memory_block(struct memory_block *mem, void *arg) { ... rc = device_offline(&mem->dev); ... /* Ignore if already offline. */ return rc < 0 ? rc : 0; } But this is a bit non-obvious, let me see about making this a little bit clearer. ~Gregory