Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2199311yba; Fri, 17 May 2019 12:18:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh91M/VhEeDS+ZsWw52BilqeeXC1WKp2fii5r09iC3K0PfNecEWqQBcDipp5EbkqRu4nHX X-Received: by 2002:a62:1a51:: with SMTP id a78mr61443421pfa.133.1558120707627; Fri, 17 May 2019 12:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558120707; cv=none; d=google.com; s=arc-20160816; b=SEb5bm0t81T2dEmrE7dVG/kvRSQW9PpF4PMDaYhFYv5xuxyPvhjOLqxR5gYP5CKG4g KZkgXrVhVrYqX2Fp5qPHsZyVXkQqpChy5ngQesW6nwNolTAW6VEmZajvzEwajXQQSVcz oVp5/c+yjbjFxNilogOEdDVsb27bJYLapTQeOeJgFHcPNGOCf6WPLjdqpU/3RkyDmHlp ZvNDKa/BY/kNNjw7xGYagGsRICzQPcmyPLNWEP/pF4MOGU+K2Pf1I180EQzloEcoCViA PNr/zuavrJO+ey2YxwlSwTijSAqGWUU1dCm4GbO+feuZdhMfH3sg7z3eZju8dOgfsd0Y DLkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0RAJ8dFkgMXY5OQlUUJ6T1gPWQG4AjdkRmpcqOy8B8o=; b=VmBjtaNcjuRyQ8ZvaGin/3ZJdUF8tgj4h8QHarbeVHagVtiTm7Z15FFpzsp1XP7ifG CcMRzrHAsdavojPsO5QR6k4ub0ckJmh4eEbrQNhXmvEkrN4wJ4zORsmcj/+Gla5Os71i 6P5W5qf4SCJDdedJWp85tioky6zf5SU6RWPKS7aTkZyYtWLknzKUw/ncFqgqsqtpHwIQ y6Qy1+hh2Wsa05WIDlPlL1QZSLefUZXqUWI8HEJFtQNBMLLntZkdz23TJM2czwvSLRiG e7a9aUxx5lvWvdJO4qCFPQCDg/Z3uyXSKBFk8UAV9fXW6vUpOLdHpWKyTIfe96VQG5+/ VKbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=N6AVNHwE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si9606995pfd.79.2019.05.17.12.18.12; Fri, 17 May 2019 12:18:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=N6AVNHwE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729165AbfEQSKR (ORCPT + 99 others); Fri, 17 May 2019 14:10:17 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:36898 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbfEQSKR (ORCPT ); Fri, 17 May 2019 14:10:17 -0400 Received: by mail-ed1-f66.google.com with SMTP id w37so11807137edw.4 for ; Fri, 17 May 2019 11:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0RAJ8dFkgMXY5OQlUUJ6T1gPWQG4AjdkRmpcqOy8B8o=; b=N6AVNHwED44tjfNeBflxf/4LK+NXnqWsv17JWf6m0n56Z8TxPCSc5PmhLfxKM9WFrq YbKovej0m6JAq0uY+V0fukul3/8snNc7VVGW3uaJCYOv9kESzesDs34u+v4WAStgHP3c sBeltk1m46EU7g2kMwLBL1Xlc9O9R/OxZjl/+/qkgn3IyGRlBAhWR9BgYqAdPvWtybzJ IgFGR1LpSroJPjuo0A0Qc1QBzB29kPQIib6uBuK0f/3Wx8viB4rvGm7IMOZPK6bLo+in ON8O8uP2Me8M1QHTOgHYyJqE46rojKl0mOXRMk3JP5y+xtGruIDjYea+Vte5dqNdk7pj Jbjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0RAJ8dFkgMXY5OQlUUJ6T1gPWQG4AjdkRmpcqOy8B8o=; b=CgQHtdWql8uKzfd5WLs6YbOx/KzUvFhFckZX3KyrFzeIH+XKUJVG0F7PBBosRiwYQc Dhrz0vZ5E9naGLXZ87lAZ8STmdZrKnz7nK4Yo2LRjfTb3stkxJnpfnuTGT/1eZ0JOIVm CoDfNVX0lbeN8c7x8t61W+losEeKlGh52qPSrwtJNg312aSiQXfTYvZ8+ksthflF3nvh 18mFyu16TKieLJXrg1u+gK/tgHQdk0vol0vGk1/iRPDTsB4stVCFUNRgUF187JTV/R6f WysBAE6h24MbJe/YvFMD1RWxp3GqAYEYGV2gIpl080QnbFSAI7SgAEkeAGcAoHYKz1fB Wk6w== X-Gm-Message-State: APjAAAU8lzQ0Sjn8in6BeJimFXoazU5G2x2IK6sAAMuZ8pm0uQJpnkij 8dVHRmML51WeDfE01h9gF/vUNvlyynrdUm3J1ZadJg== X-Received: by 2002:a50:ee01:: with SMTP id g1mr58841265eds.263.1558116615828; Fri, 17 May 2019 11:10:15 -0700 (PDT) MIME-Version: 1.0 References: <20190502184337.20538-1-pasha.tatashin@soleen.com> <20190502184337.20538-3-pasha.tatashin@soleen.com> In-Reply-To: From: Pavel Tatashin Date: Fri, 17 May 2019 14:10:04 -0400 Message-ID: Subject: Re: [v5 2/3] mm/hotplug: make remove_memory() interface useable To: Dan Williams Cc: Dave Hansen , James Morris , Sasha Levin , Linux Kernel Mailing List , Linux MM , linux-nvdimm , Andrew Morton , Michal Hocko , Dave Hansen , Keith Busch , Vishal L Verma , Dave Jiang , Ross Zwisler , Tom Lendacky , "Huang, Ying" , Fengguang Wu , Borislav Petkov , Bjorn Helgaas , Yaowei Bai , Takashi Iwai , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan, Thank you very much for your review, my comments below: On Mon, May 6, 2019 at 2:01 PM Dan Williams wrote: > > On Mon, May 6, 2019 at 10:57 AM Dave Hansen wrote: > > > > > -static inline void remove_memory(int nid, u64 start, u64 size) {} > > > +static inline bool remove_memory(int nid, u64 start, u64 size) > > > +{ > > > + return -EBUSY; > > > +} > > > > This seems like an appropriate place for a WARN_ONCE(), if someone > > manages to call remove_memory() with hotplug disabled. I decided not to do WARN_ONCE(), in all likelihood compiler will simply optimize this function out, but with WARN_ONCE() some traces of it will remain. > > > > BTW, I looked and can't think of a better errno, but -EBUSY probably > > isn't the best error code, right? -EBUSY is the only error that is returned in case of error by real remove_memory(), so I think it is OK to keep it here. > > > > > -void remove_memory(int nid, u64 start, u64 size) > > > +/** > > > + * remove_memory > > > + * @nid: the node ID > > > + * @start: physical address of the region to remove > > > + * @size: size of the region to remove > > > + * > > > + * NOTE: The caller must call lock_device_hotplug() to serialize hotplug > > > + * and online/offline operations before this call, as required by > > > + * try_offline_node(). > > > + */ > > > +void __remove_memory(int nid, u64 start, u64 size) > > > { > > > + > > > + /* > > > + * trigger BUG() is some memory is not offlined prior to calling this > > > + * function > > > + */ > > > + if (try_remove_memory(nid, start, size)) > > > + BUG(); > > > +} > > > > Could we call this remove_offline_memory()? That way, it makes _some_ > > sense why we would BUG() if the memory isn't offline. It is this particular code path, the second one: remove_memory(), actually tries to remove memory and returns failure if it can't. So, I think the current name is OK. > > Please WARN() instead of BUG() because failing to remove memory should > not be system fatal. As mentioned earlier, I will keep BUG(), because existing code does that, and there is no good handling of this code to return on error. Thank you, Pavel