Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp508723ybh; Wed, 11 Mar 2020 05:31:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvgQIP8ImUHe6ZWgkKlTygAgz7pAaKgyvWkH26xfD+n43mwziRI0TBT6OeNoEWdQMaBugC+ X-Received: by 2002:a05:6830:210f:: with SMTP id i15mr2097145otc.335.1583929874322; Wed, 11 Mar 2020 05:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583929874; cv=none; d=google.com; s=arc-20160816; b=mOut41nPO/7+4ZvwNTfuSd16Ch7YQZGr8UQntEEcmaksrci7Q7tTaCM7bHdicshLnk CZMBSgK8CKa8e1iMzvZZbX781dUOqk/qKlm1q0UixyLLDsKHeb51rGZQ/VxzrAWY1CwQ OU0McyDq8TSD7BU2P6R97XnHAkxZUaD2RHSbiuc9uEiFb3GFzMT+B0TJwJWWoQIurKza 0ncEN+4dp3rpAxX+Kf5kHg7wpKWsoPeqSkN3qhi8mPMhyRj0XXyidedqJoD5UPpNlYFW HgrjvrfBUH/PCxm6ftFzWzuesTRbQrZN9Yc82mngmzWU52xbnoUYc4c1mBH1cNLfZL5L syYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UUlE+YB0rqBWRKtiAZBO49OVQNayl/pvbY6RAY5FLgE=; b=peeA5gh4v2oFMsOPKkQ2lIFmKCVedFrcCYflbIwYlaRr11u7npjrzSvuK6Lld9hBVq m9S+fOEQAcRZnxiwhEIaR+K6Vuu2zhYdjOmTlhTSHYMf0c57ICOVjvr/b39ALjMcZaRE SXVtB+mT7OCtK4kc3egKiGmXmOvurjKGbj881CjtFKHUAgyShvwW6pT2T1JAcrmXyGk/ GRy7fre1dci6DcZfxXRGfjkc9RnpoSjJmnGSF2KODZesGz168go+9hYn4oQgKkGhkKmY aSc2pFZoxI6UzG8Pu3QSd1kt6zNsr0J2T668C9t9o2z6vj2f2PsEIliVQihJERLpKCwD y0Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fygbu2zY; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p203si982334oic.214.2020.03.11.05.31.03; Wed, 11 Mar 2020 05:31:14 -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=@redhat.com header.s=mimecast20190719 header.b=fygbu2zY; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729354AbgCKMar (ORCPT + 99 others); Wed, 11 Mar 2020 08:30:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38488 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729239AbgCKMar (ORCPT ); Wed, 11 Mar 2020 08:30:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583929846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UUlE+YB0rqBWRKtiAZBO49OVQNayl/pvbY6RAY5FLgE=; b=fygbu2zYTEaPjfPFeL0k0AvlLuctIo6oJgfdyBE3JhSu59/og/mIbD6UzXMnLeU3vHBekS OFYZ/v3oNmTwRAEtTGJ8oyw40OpKY7bbgbSIEiGXZoAc2cfa7l7YvRzyLNLHlip5tDzM+H ORW0jamQmuma0Z1Y+cUEAKwBiIHxHmY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-UdNuObYhN5-vHqPlUF5hbg-1; Wed, 11 Mar 2020 08:30:44 -0400 X-MC-Unique: UdNuObYhN5-vHqPlUF5hbg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B1CA801E53; Wed, 11 Mar 2020 12:30:43 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.36.118.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAF6B5C1D4; Wed, 11 Mar 2020 12:30:40 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, David Hildenbrand , Greg Kroah-Hartman , Andrew Morton , Michal Hocko , Oscar Salvador , "Rafael J. Wysocki" , Baoquan He , Wei Yang Subject: [PATCH v1 2/5] drivers/base/memory: map MMOP_OFFLINE to 0 Date: Wed, 11 Mar 2020 13:30:23 +0100 Message-Id: <20200311123026.16071-3-david@redhat.com> In-Reply-To: <20200311123026.16071-1-david@redhat.com> References: <20200311123026.16071-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; =20 /* - * If we are called from state_store(), online_type will be - * set >=3D 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 =3D=3D MMOP_OFFLINE) mem->online_type =3D MMOP_ONLINE; =20 ret =3D memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); - - /* clear online_type */ - mem->online_type =3D -1; + mem->online_type =3D MMOP_OFFLINE; =20 return ret; } diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplu= g.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 =3D -1, + MMOP_OFFLINE =3D 0, /* Online the memory. Zone depends, see default_zone_for_pfn(). */ MMOP_ONLINE, /* Online the memory to ZONE_NORMAL. */ --=20 2.24.1