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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 439B2C07E9C for ; Wed, 7 Jul 2021 07:32:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AFE5761CAA for ; Wed, 7 Jul 2021 07:32:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFE5761CAA 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 9686B6B005D; Wed, 7 Jul 2021 03:32:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93FAE6B006C; Wed, 7 Jul 2021 03:32:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DF716B0070; Wed, 7 Jul 2021 03:32:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id 55B726B005D for ; Wed, 7 Jul 2021 03:32:25 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BB9B325705 for ; Wed, 7 Jul 2021 07:32:24 +0000 (UTC) X-FDA: 78334973808.05.C055D0F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 691EC1994 for ; Wed, 7 Jul 2021 07:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625643143; 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=E1X6mDwvWEwCM4qkv2vY7/L/oZAtoLR8LCFJEbDinOo=; b=Tl4NYRGtJm3k9wD2S0RvXTE6CpqvhVbm6NYQ1FIPEhJfITpdb6CIoUBfgQDqKUlQLsfa6s EXPemjYpzMlJTwids/Seuiw5U7/yNrpC9AAI3ENWpvSOLNH5o6Jrspf2ntAqiaMk6UO/R0 t0MQe97ZAbEJ4Aewe7aV1l24yvIQr84= 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-249-XijirgdYPz2__IPr89VNLQ-1; Wed, 07 Jul 2021 03:32:22 -0400 X-MC-Unique: XijirgdYPz2__IPr89VNLQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3DB5A40C0; Wed, 7 Jul 2021 07:32:19 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-110.ams2.redhat.com [10.36.114.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1588460CC9; Wed, 7 Jul 2021 07:32:14 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Anshuman Khandual , Dave Hansen , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Mike Kravetz , Mike Rapoport , Mike Rapoport , Muchun Song , Oscar Salvador , Pavel Tatashin , Stephen Rothwell , linux-doc@vger.kernel.org Subject: [PATCH resend v3 1/2] memory-hotplug.rst: remove locking details from admin-guide Date: Wed, 7 Jul 2021 09:32:04 +0200 Message-Id: <20210707073205.3835-2-david@redhat.com> In-Reply-To: <20210707073205.3835-1-david@redhat.com> References: <20210707073205.3835-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 691EC1994 X-Stat-Signature: 7xtmbqxy354noqa35i8irem35zhe57p8 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tl4NYRGt; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf22.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1625643144-199338 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: We have the same content at Documentation/core-api/memory-hotplug.rst and it doesn't fit into the admin-guide. The documentation was accidentially duplicated when merging. Acked-by: Mike Rapoport Acked-by: Michal Hocko Reviewed-by: Oscar Salvador Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: Mike Kravetz Cc: Mike Rapoport Cc: Dave Hansen Cc: Matthew Wilcox Cc: Anshuman Khandual Cc: Muchun Song Cc: Pavel Tatashin Cc: Jonathan Corbet Cc: Stephen Rothwell Cc: linux-doc@vger.kernel.org Signed-off-by: David Hildenbrand --- .../admin-guide/mm/memory-hotplug.rst | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentat= ion/admin-guide/mm/memory-hotplug.rst index c6bae2d77160..a783cf7c8e4c 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -415,45 +415,6 @@ Need more implementation yet.... - Guard from remove if not yet. =20 =20 -Locking Internals -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -When adding/removing memory that uses memory block devices (i.e. ordinar= y RAM), -the device_hotplug_lock should be held to: - -- synchronize against online/offline requests (e.g. via sysfs). This way= , memory - block devices can only be accessed (.online/.state attributes) by user - space once memory has been fully added. And when removing memory, we - know nobody is in critical sections. -- synchronize against CPU hotplug and similar (e.g. relevant for ACPI an= d PPC) - -Especially, there is a possible lock inversion that is avoided using -device_hotplug_lock when adding memory and user space tries to online th= at -memory faster than expected: - -- device_online() will first take the device_lock(), followed by - mem_hotplug_lock -- add_memory_resource() will first take the mem_hotplug_lock, followed b= y - the device_lock() (while creating the devices, during bus_add_device()= ). - -As the device is visible to user space before taking the device_lock(), = this -can result in a lock inversion. - -onlining/offlining of memory should be done via device_online()/ -device_offline() - to make sure it is properly synchronized to actions -via sysfs. Holding device_hotplug_lock is advised (to e.g. protect onlin= e_type) - -When adding/removing/onlining/offlining memory or adding/removing -heterogeneous/device memory, we should always hold the mem_hotplug_lock = in -write mode to serialise memory hotplug (e.g. access to global/zone -variables). - -In addition, mem_hotplug_lock (in contrast to device_hotplug_lock) in re= ad -mode allows for a quite efficient get_online_mems/put_online_mems -implementation, so code accessing memory can protect from that memory -vanishing. - - Future Work =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.31.1