Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp606398ybh; Wed, 11 Mar 2020 07:19:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu/1jP0T8wDheRixfifYFzBjQjgik47IXIkhAQRq+whfcbuBYd9QoAo3s62aOmIpyl9sCOy X-Received: by 2002:a9d:7695:: with SMTP id j21mr2586502otl.157.1583936379931; Wed, 11 Mar 2020 07:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583936379; cv=none; d=google.com; s=arc-20160816; b=tC9UX+vF+oNAbdHP6LfxRTThxKXPa3/q2ugaUbUjMH/fK0t5hRevh0EygWQO26F47Z 6QpnFUzv92MguCuWHUZRqK6Cc19C6t34Mw18gbJ0juJ0rVEFrJkI4h0ml4jKmEXKZDA+ kmzl0HzndMD1iJAe+X/+2fcA9ZFSTD821tSF2+NscbHFAqjhYD/zy4YP70xqH+dbHjbc VG48SgO4MAsqsXMv8vLRFkf2yx4MyPmrNK/YsBO5W8pl7yRka04rvlyS74PGF1RIKDZf 62P3bCFp4xYUTMtHDzVs1l/gFvJ96UNL5YHf5SvG5Z9mfwnwlAtn0AXq83y+aS8SCMfa SQ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=UlqHsGcMH2wgZ4HNYQSAfQVihbtUyreW0G2xFxwpzcs=; b=igEWvOALhBjhtA1myTzajY32uhXW05aA0B3A2fT0Z6/z5hYiPsG4III5IibEO68a96 Nvp4gSANxeG3bCtnA4WUPVDPbDOGAp8I/kF6ukztVTzKkKZCWDxWZAntXzXPhXWluTco 0sV2xPxSYXFnYRiSLyVX/h+WxcaG4N1MPeqSuE0YH+KQrbZac7Wu1kw5mRrXjHemdFkR 3Syi7ZC7Znfo/vOJfhc7NrZ5j8a7zk1bWmUm4wdO+uy6J7CR2QN4fMPIaERlY/O/FBVM YFhQ+M0he4gHlSZRvYRDl+3vjEk2ZSLN1DCIW7WWG8SNU7IrAWQNBxFJUna1qBRovJTa ojpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PdYhcmI7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o64si1245202oib.72.2020.03.11.07.19.18; Wed, 11 Mar 2020 07:19:39 -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=@gmail.com header.s=20161025 header.b=PdYhcmI7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729812AbgCKOSZ (ORCPT + 99 others); Wed, 11 Mar 2020 10:18:25 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40664 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729798AbgCKOSZ (ORCPT ); Wed, 11 Mar 2020 10:18:25 -0400 Received: by mail-wr1-f66.google.com with SMTP id p2so2839497wrw.7; Wed, 11 Mar 2020 07:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UlqHsGcMH2wgZ4HNYQSAfQVihbtUyreW0G2xFxwpzcs=; b=PdYhcmI7s3rv/HMRFF/5hUVPIoLN4hdtpSANHt1mmnYHd7bvwLK/oGC56J9RethYth +H9fjEMKeBDyP/sBCAjJGnkXzzwhlfGin+8iMaNGcxpbvbV96pZBQ/UBopbr7B8cFg8S SxYq5gUPBKhAJN4jVfyflW8sGzRweWAD/9keqVDhqxMMFgL9Y7gblvTCpa+iZ6JrITEk H+HlG2w8NvqamdHQMk0ZRPotGvpBILQmL3bJzWVVCH3OErZjB9v7FgdeReAzV5OhB5w1 1tFvQ+9MhnRGDXTkpuiIoE7rS6bxZrBxBw5RLfp9G3hvhDa8QMIhm2Reb52dR9/wC1BX LpJQ== 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:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=UlqHsGcMH2wgZ4HNYQSAfQVihbtUyreW0G2xFxwpzcs=; b=pxjY5zXlk6GvWBjrC5Mm/bPXpkiEj0g4QFAFXbhqm0Ys9J201hy5GkU5HHIOJdEkoU MIMvs99H03pPE81hUGQyfquhDaskscmXlQhdd1bNqikxYgcuNzTgujNuHAQfYsI46swa tREyZVPx7/iLhLwYKTOxyMl5rxujJwqBRFyUKgcN8qRfOpGV3xE6BCUHw1tAnVfiHkEI V1MilP/U/AjKJdmRM0pvv8LlsIbitJjw0nIKCHQCLzWTKLGhfvkEJ/Dmdx/m8XwgaIDT fZKiIWNop+J2hwhZxqH0HA8cQS4weoIe4VZZqYH6XluK7QMII2SgbT0dHlOdYAJyaeOr 3igg== X-Gm-Message-State: ANhLgQ1yhBGmUS6muyTLggI6B9OihSAm7YDh6yuWwBRWP+rhUWEdNMZ7 Bpu0jgJhb+jypyZIuFT5BgRxu4GR X-Received: by 2002:a05:6000:100d:: with SMTP id a13mr4580847wrx.234.1583936301649; Wed, 11 Mar 2020 07:18:21 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id q4sm26328172wro.56.2020.03.11.07.18.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Mar 2020 07:18:21 -0700 (PDT) Date: Wed, 11 Mar 2020 14:18:20 +0000 From: Wei Yang 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 , Michal Hocko , 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: <20200311141820.zgmwiz3rdj5co6kf@master> Reply-To: Wei Yang 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> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 01:30:23PM +0100, David Hildenbrand wrote: >I have no idea why we have to start at -1. 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. > >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 Reviewed-by: Wei Yang >--- > 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 -- Wei Yang Help you, Help me