Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2757750yba; Mon, 6 May 2019 11:02:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqysh6oMSrQuD6KGsc5lDSLNAnblW8iWOA7weNIAo33dgk+/YlUAsFAxLYRHmQbOiw8wEpkx X-Received: by 2002:a63:3:: with SMTP id 3mr33031812pga.360.1557165762432; Mon, 06 May 2019 11:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557165762; cv=none; d=google.com; s=arc-20160816; b=O6+tJpo/BeRgNt0fTQJo3XxTe7fpEX6PzHEQXQnDEnRF3KzRZC2i/IlsI5jfS4XA6u 4XER+G1I18EfpFJlXxfJJL8vdpusiF8Aa6y/4KI1PwOuciuYqGk3VqUfKlgxEJK4ZjO1 w/mZrluVgjYB6e26oVxGck6SJSwRi7c7Vbc4HBHDjOUCNSYZraa8X7IGlRbCAFb4Th6P Nu0Is8gf4pcz4r6G1fHpbLQx8BE9rXg3mSCqnwEdOZyhW5js4Ky7wq2OGxObZ2TX99b7 U8iW0KI7cM4XVtCu1lN8YB41bpwW8R/uftBAQQfDkDCKzWXvEy4H5l5dyKTa4AGBbLxz Jv9Q== 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=s1iYiXewvQHx5myE/g1Y4h4JHD9obTw48tmYZs0bXqI=; b=ebiVA1OQ4YbXGWH+SUzsOwJ5tT6bzq/xRJHSO6YFEo7rvWWLknXnlE8cgC0QZwQMCy hBg+/xkwO+cw9VSItCyEUy78JwldSdm1kUuXx11/UPjvd7OmTfsx0eitGJsxicLRQXHa 3IyHqVuft825I68g67a/f7tuV9HH+4J0SQFdULDpHk6DoVbWDHIFbmQkwYZuuIb2LIzH sqhS3DlqT3lbVV2A2cwn4mjhP/IHwJm/7TYUSAbKnocVh04W7W/5+dAmqzqpeqH7m1OE VST0jxU7mm8sHppPjVdAe0fNkwpDENpjeueUKtHJC2RWwII1onNQRpAwjtXWT6IiVYOc f1sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Gesm1Mat; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si819411plc.181.2019.05.06.11.02.24; Mon, 06 May 2019 11:02:42 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Gesm1Mat; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbfEFSB0 (ORCPT + 99 others); Mon, 6 May 2019 14:01:26 -0400 Received: from mail-ot1-f48.google.com ([209.85.210.48]:38714 "EHLO mail-ot1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfEFSB0 (ORCPT ); Mon, 6 May 2019 14:01:26 -0400 Received: by mail-ot1-f48.google.com with SMTP id b1so12341463otp.5 for ; Mon, 06 May 2019 11:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s1iYiXewvQHx5myE/g1Y4h4JHD9obTw48tmYZs0bXqI=; b=Gesm1Mat5Nvdr9Z6ppAbheRkkXki5hmEJfki+aAZEgQWtXeZOTMMrgHdcrUMVJlQDM EoFBqW0epQyBVW0aMfUQWMZnSCnDG8Y/vtE5zcyaAH6Zdl9pu/EraJnHe6FBYcMXyLyp VZWggnrv7fI/MHQOhvLueK8w7k5e1LgXjHwFDufU47j2WbehxdNld3it11T/RfmzXJrP ljgYCI7GsW9S1KDe1lCVZ4mK3cyWa3kT8S9i8NiXyvnLEBSmbjhWarFP7+6KuIOEkME3 7O9VFfUN9zNq29/cUxKNj4nEuJwTTMN48lYv1nIyegLPGtL2vWXAzQYZsJ+V1TQeTBnW 0sdA== 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=s1iYiXewvQHx5myE/g1Y4h4JHD9obTw48tmYZs0bXqI=; b=N2/jQrSU98T/8re8Nd0X6RAH2BNn53sXpFZxoz+cFTIKhtD9SpQE15bjgW7Rs8tsfy vWxMT2lwtbUCdwzmNwpCNpXliCAOj0c7nS77LvIoxKBTWRvrVm/G06HLUgt4aaP27xf6 HW20WrBlZELHjF7FfcC6OLLTbj4trsp8H+nZvj4qlxAWYz0rI3xyyxR/CfFrbYDGN6+T q5G3ZBb3kuzUiQ4xlNLgK9gsqg0e7noEuiDPxxbFV5Bvbw8g9A0IMcvC/KvFeSaMPKLC 6FLZQ2ka2yPVaNUn1NspwH70QQSoZWzmrq5Ep1jcXa+RgPGSPnaws3TWpk8by4F4hrBg Kz7g== X-Gm-Message-State: APjAAAUzRqXgrpqcHAemwpW9suuhN1zfk/n3nqdkMkaAQVOeJQ288GWM werviiJaYVygjMJjfnzie39cX4m27p7I4l61QF939w== X-Received: by 2002:a9d:7ad1:: with SMTP id m17mr17304018otn.367.1557165685323; Mon, 06 May 2019 11:01:25 -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: Dan Williams Date: Mon, 6 May 2019 11:01:14 -0700 Message-ID: Subject: Re: [v5 2/3] mm/hotplug: make remove_memory() interface useable To: Dave Hansen Cc: Pavel Tatashin , 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 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. > > BTW, I looked and can't think of a better errno, but -EBUSY probably > isn't the best error code, right? > > > -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. Please WARN() instead of BUG() because failing to remove memory should not be system fatal.