From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FF40C32771 for ; Mon, 27 Jan 2020 11:04:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1843D208CD for ; Mon, 27 Jan 2020 11:04:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NWpEndZK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1843D208CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BD8336B0006; Mon, 27 Jan 2020 06:04:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B89046B0007; Mon, 27 Jan 2020 06:04:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A777F6B0008; Mon, 27 Jan 2020 06:04:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 931876B0006 for ; Mon, 27 Jan 2020 06:04:40 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 5191C8248047 for ; Mon, 27 Jan 2020 11:04:40 +0000 (UTC) X-FDA: 76423131120.28.beef76_ba377d34ae43 X-HE-Tag: beef76_ba377d34ae43 X-Filterd-Recvd-Size: 6493 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Jan 2020 11:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580123079; 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=LIk00X/KXVdbLkFtuKPrEpZyGO0RG3xstfsngS1E1yw=; b=NWpEndZKlWrJ+3e2x4+5Gn+JgzpiQnhsMxS5BiINhT6N17taSnfw7HKOpofpN0uV4L5PIV vQPnugeUcyxLbJgL0F9Wjo7LZT6sj9Nd2OTytlo5WdnOhyJmB6yFDKQLTu8Dcei039KO4M 6539RvgmMoxBvjvhLWcslvd1NPKJjPw= 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-114-DEOqPzKLM7u2wxz8DVsayw-1; Mon, 27 Jan 2020 06:04:35 -0500 X-MC-Unique: DEOqPzKLM7u2wxz8DVsayw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DB901083E95; Mon, 27 Jan 2020 11:04:33 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.36.118.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D20D19E9C; Mon, 27 Jan 2020 11:04:31 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Michal Hocko , Dan Williams , Pavel Tatashin , Anshuman Khandual Subject: [PATCH v1 1/3] drivers/base/memory.c: drop section_count Date: Mon, 27 Jan 2020 12:04:22 +0100 Message-Id: <20200127110424.5757-2-david@redhat.com> In-Reply-To: <20200127110424.5757-1-david@redhat.com> References: <20200127110424.5757-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since commit c5e79ef561b0 ("mm/memory_hotplug.c: don't allow to online/offline memory blocks with holes") we have a generic check in offline_pages() that disallows offlining memory blocks with holes. Memory blocks with missing sections are just another variant of these type of blocks. We can stop checking (and especially storing) present sections. A proper error message is now printed why offlining failed. section_count was initially introduced in commit 07681215975e ("Driver core: Add section count to memory_block struct") in order to detect when it is okay to remove a memory block. It was used in commit 26bbe7ef6d5c ("drivers/base/memory.c: prohibit offlining of memory blocks with missing sections") to disallow offlining memory blocks with missing sections. As we refactored creation/removal of memory devices and have a proper check for holes in place, we can drop the section_count. This also removes a leftover comment regarding the mem_sysfs_mutex, which was removed in commit 848e19ad3c33 ("drivers/base/memory.c: drop the mem_sysfs_mutex"). Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Michal Hocko Cc: Dan Williams Cc: Pavel Tatashin Cc: Anshuman Khandual Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 17 +++-------------- include/linux/memory.h | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 6503f5d0b749..852fece9be1d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -292,10 +292,6 @@ static int memory_subsys_offline(struct device *dev) if (mem->state =3D=3D MEM_OFFLINE) return 0; =20 - /* Can't offline block with non-present sections */ - if (mem->section_count !=3D sections_per_block) - return -EINVAL; - return memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE); } =20 @@ -660,7 +656,7 @@ static int init_memory_block(struct memory_block **me= mory, =20 static int add_memory_block(unsigned long base_section_nr) { - int ret, section_count =3D 0; + int section_count =3D 0; struct memory_block *mem; unsigned long nr; =20 @@ -671,12 +667,8 @@ static int add_memory_block(unsigned long base_secti= on_nr) =20 if (section_count =3D=3D 0) return 0; - ret =3D init_memory_block(&mem, base_memory_block_id(base_section_nr), - MEM_ONLINE); - if (ret) - return ret; - mem->section_count =3D section_count; - return 0; + return init_memory_block(&mem, base_memory_block_id(base_section_nr), + MEM_ONLINE); } =20 static void unregister_memory(struct memory_block *memory) @@ -714,7 +706,6 @@ int create_memory_block_devices(unsigned long start, = unsigned long size) ret =3D init_memory_block(&mem, block_id, MEM_OFFLINE); if (ret) break; - mem->section_count =3D sections_per_block; } if (ret) { end_block_id =3D block_id; @@ -723,7 +714,6 @@ int create_memory_block_devices(unsigned long start, = unsigned long size) mem =3D find_memory_block_by_id(block_id); if (WARN_ON_ONCE(!mem)) continue; - mem->section_count =3D 0; unregister_memory(mem); } } @@ -752,7 +742,6 @@ void remove_memory_block_devices(unsigned long start,= unsigned long size) mem =3D find_memory_block_by_id(block_id); if (WARN_ON_ONCE(!mem)) continue; - mem->section_count =3D 0; unregister_memory_block_under_nodes(mem); unregister_memory(mem); } diff --git a/include/linux/memory.h b/include/linux/memory.h index 0b8d791b6669..439a89e758d8 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -26,7 +26,6 @@ struct memory_block { unsigned long start_section_nr; unsigned long state; /* serialized by the dev->lock */ - int section_count; /* serialized by mem_sysfs_mutex */ int online_type; /* for passing data to online routine */ int phys_device; /* to which fru does this belong? */ struct device dev; --=20 2.24.1