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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 1D14AC47082 for ; Tue, 8 Jun 2021 14:19:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F215B61363 for ; Tue, 8 Jun 2021 14:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233218AbhFHOVV (ORCPT ); Tue, 8 Jun 2021 10:21:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233129AbhFHOVU (ORCPT ); Tue, 8 Jun 2021 10:21:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 348BA6135D; Tue, 8 Jun 2021 14:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623161967; bh=vgomed/fFV+dy2eA01Kw/duzevIkt+qd3SY8fxSJQqQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F8y/iDcySfPiZkIvhGmow9mMEg9/j+KXYzhWk4FubYL/3zr27JWltTfjxBoQ8UQnK jpFCivxVElEYPE8vgGcOPiQLoZMDGWv99OcClsUMcuHXiCpHF5hwJTS5sTJ2jJ7UPi fSRxxu4hRl3sCuzNE3aTywoIC/KD4ADu1crThHbsTlkQ40Rh9uk6X+tPAkBzl8xff8 9lBU+n4ccZyI9KOI3qiiZvFYGi70sth7VVpImUup8d3N64Y74QdJzwo4LAi1qQHGwV HqSNa9aPcQ/1+4VKOzQuQ4mtNr1nTgKDLYNIi9Br8l0UyiTazHessLkcXd17cdSzl3 /IuQSo5CeFYQg== Date: Tue, 8 Jun 2021 17:19:17 +0300 From: Mike Rapoport To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Anshuman Khandual , Dave Hansen , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Mike Kravetz , Muchun Song , Oscar Salvador , Pavel Tatashin , Stephen Rothwell , linux-doc@vger.kernel.org Subject: Re: [PATCH v2 1/2] memory-hotplug.rst: remove locking details from admin-guide Message-ID: References: <20210608133855.20397-1-david@redhat.com> <20210608133855.20397-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210608133855.20397-2-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Tue, Jun 08, 2021 at 03:38:54PM +0200, David Hildenbrand wrote: > 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. > > 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 Acked-by: Mike Rapoport > --- > .../admin-guide/mm/memory-hotplug.rst | 39 ------------------- > 1 file changed, 39 deletions(-) > > diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/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. > > > -Locking Internals > -================= > - > -When adding/removing memory that uses memory block devices (i.e. ordinary 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 and PPC) > - > -Especially, there is a possible lock inversion that is avoided using > -device_hotplug_lock when adding memory and user space tries to online that > -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 by > - 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 online_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 read > -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 > =========== > > -- > 2.31.1 > -- Sincerely yours, Mike.