Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2714267ybh; Mon, 16 Mar 2020 08:21:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt1swCUEmCbIFGhEj1GmaAZeZgbvyzZtHXx3au2uHI13G0Xl01qfxqoySmDvQ5EiuDNJ1y5 X-Received: by 2002:aca:fd44:: with SMTP id b65mr17113oii.119.1584372062251; Mon, 16 Mar 2020 08:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584372062; cv=none; d=google.com; s=arc-20160816; b=pxUeusLT6nORJnFN76M0UYrHj5Xm+EYtRoUPHVnDv0BIhX79YY808+dPSztscv1w5+ 42VvAJ9IDU16AonTuuMGdlFOC0t5miJ7AFc96DeSkUqVd9HGFLwAgwILxHC/P6kw6gtt 2nnFIKSRVe/LlraWFB9MDxRpUg0yHeXiLr/k5tzl/v6Nv6/hefy0BzxDJPn+kw0hYofK Xaa8eRdUqmQ11b/Q3LWAOeBRO6m+hNWEtt8CA7sd8w/r56AHRtJPxiM0gGiOeNYXMySq 2Q89DE4z1TyxwugiuT1Y8pTpliFkwA/Wf01qjTRoF7mXVsJ7XALRwGgHL6AmEUAaNFes TSww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9gCLfTwG3giIuIHsNt54BqZ2oPFCe851NK97n7eWk0U=; b=jHa/uREDcoa4YxsSDuxA81M90+cBGUBs4ndTchxA7xOZ8ohydS14MVVRoYWIrd+697 cBxq7NzlUuULJcdMM0749rHxnZI3vF1Iy+DItY0/QLSied2ZxwXHQnkT9+kZp9IgP5uT w5ZLdVUoutp32wFIEcitak5m0dgKjpNBLfORxS1lsvmvfXUIR0bW5b9IhU0Wxa9xeZDM lpvgN9DyFSliWDs5R0Bkc1N7Nqonz7Oz4Au+1liBxlbPtlWadTB6bWosC95msLtHJc4b TUybSwV6f6kSXWtUm6XpzLssV5mrPjHu5g9NzX6Y4n1oUQgt9JqxUJ8Y59D5rH32NIJF xZaw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si142446oib.46.2020.03.16.08.20.47; Mon, 16 Mar 2020 08:21:02 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731715AbgCPPT0 (ORCPT + 99 others); Mon, 16 Mar 2020 11:19:26 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38289 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729856AbgCPPT0 (ORCPT ); Mon, 16 Mar 2020 11:19:26 -0400 Received: by mail-wm1-f66.google.com with SMTP id t13so12164402wmi.3; Mon, 16 Mar 2020 08:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9gCLfTwG3giIuIHsNt54BqZ2oPFCe851NK97n7eWk0U=; b=kjAsd3vqIDXPBheSE4Ep3nle0/UXfTq4ajDnjCnQBA3a4wA1FJ2epKcA0mgchyjSgs bZiQMO2Oxk6U5j/4pNPj4BStVgc2Ub6b+EjAgX+N6UpDiV14stVDgStnDjxc3LMcglC1 jGwPizkc4Oqy7lMtV7IzXMBdXhfwmdY+jzJNFQFMW2EbFm6xoHWhncTFCUkcrkjXnSVi 3VQNFLVi34INX/r/j4eTUYAP7s6JuD9lirX4p8SXEGIIdIor2ZOhKX850DbjBrFZt82G MVYEZE335ILbUGP2PpOQ0QmEvGiIfL+nQvtIJOoBjNNB/KlvGU4oX8zudJmQnhKZtGi5 lO8w== X-Gm-Message-State: ANhLgQ0MAnaKRYHtxcWaDnAIz9WPrHz2F6GLTaG679D9CHtlmSQsBeiq QZGIr+5qoQ+PPv53tAJ7zD4= X-Received: by 2002:a7b:c0cf:: with SMTP id s15mr29520903wmh.106.1584371964191; Mon, 16 Mar 2020 08:19:24 -0700 (PDT) Received: from localhost ([37.188.132.163]) by smtp.gmail.com with ESMTPSA id w204sm79069wma.1.2020.03.16.08.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 08:19:23 -0700 (PDT) Date: Mon, 16 Mar 2020 16:19:22 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , Oscar Salvador , "Rafael J. Wysocki" , Baoquan He , Wei Yang Subject: Re: [PATCH v1 2/5] drivers/base/memory: map MMOP_OFFLINE to 0 Message-ID: <20200316151922.GT11482@dhcp22.suse.cz> References: <20200311123026.16071-1-david@redhat.com> <20200311123026.16071-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311123026.16071-3-david@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 11-03-20 13:30:23, David Hildenbrand wrote: > I have no idea why we have to start at -1. Because this is how the offline state offline was represented originally. > Just treat 0 as the special > case. Clarify a comment (which was wrong, when we come via > device_online() the first time, the online_type would have been 0 / > MEM_ONLINE). The default is now always MMOP_OFFLINE. git grep says that you have covered the only remaining place which hasn't used the enum value. > This is a preparation to use the online_type as an array index. > > Cc: Greg Kroah-Hartman > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Oscar Salvador > Cc: "Rafael J. Wysocki" > Cc: Baoquan He > Cc: Wei Yang > Signed-off-by: David Hildenbrand Acked-by: Michal Hocko > --- > drivers/base/memory.c | 11 ++++------- > include/linux/memory_hotplug.h | 2 +- > 2 files changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index 8c5ce42c0fc3..e7e77cafef80 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -211,17 +211,14 @@ static int memory_subsys_online(struct device *dev) > return 0; > > /* > - * If we are called from state_store(), online_type will be > - * set >= 0 Otherwise we were called from the device online > - * attribute and need to set the online_type. > + * When called via device_online() without configuring the online_type, > + * we want to default to MMOP_ONLINE. > */ > - if (mem->online_type < 0) > + if (mem->online_type == MMOP_OFFLINE) > mem->online_type = MMOP_ONLINE; > > ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); > - > - /* clear online_type */ > - mem->online_type = -1; > + mem->online_type = MMOP_OFFLINE; > > return ret; > } > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 261dbf010d5d..c2e06ed5e0e9 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -48,7 +48,7 @@ enum { > /* Types for control the zone type of onlined and offlined memory */ > enum { > /* Offline the memory. */ > - MMOP_OFFLINE = -1, > + MMOP_OFFLINE = 0, > /* Online the memory. Zone depends, see default_zone_for_pfn(). */ > MMOP_ONLINE, > /* Online the memory to ZONE_NORMAL. */ > -- > 2.24.1 -- Michal Hocko SUSE Labs