Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4616389pxj; Tue, 8 Jun 2021 19:57:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjellXIP230vGxxR3D31uoapUOfcxkfeg2S2A/0APJTrfS/ffz3JdrFKA4KNk8995ZUdO9 X-Received: by 2002:a17:907:9618:: with SMTP id gb24mr5535025ejc.111.1623207459160; Tue, 08 Jun 2021 19:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623207459; cv=none; d=google.com; s=arc-20160816; b=nU6y+ZTZE27uvenw7Y9ev7XE5L1yHX0Wejo5Kozzf6lCKPf5TvvoFRhZsHeJTHjaEG AV0WXzRUnfUN686QhokVUqAS4SzyUBeBtBDgqidjc6hEyIndnoFKDBmGFo+MiP5Qcn26 mIio/7kPOiahTXKFUraWblEvWcI7ZWTyAikhEnRLayaN7IHVaIgAUbQdGg+AlcvN35lO oZdf5pPbg5wSnE04ymTTt4XPe6v0jKQNn8uca8u9/c5FTsBgOa372Z6IJ9DTckV+g876 bR4Aks2raAERD/ORYff3li6FVlMqNB6gMopyhzcB8BHDBkcp8QWgtdY4vh9612m0C1FN WuQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CF3V2yBluejgpXrXpzIa28hHGX5nHnF0ElTMo/4V698=; b=uDGMvhPM8Ls9axJAiFBlCWj153K8LvN8Mkef2IIBuaW5uAUkwLb+nGOOP6suBmOr05 meMLyHsAyIMZdmeFzwtNTIgrt/Lf+ipoACqeJ7Ppf5YNRMUsVtsfonSB1lj63Ywhpt6j BddlA9q07AtpdEDl07aoDF/AjoG7YHjswpfvCi7p0QGd+//n+vV4EWuLSjgHLjtmHYbc 0pdqtCe2HAapVS+Vnr6bB7cv4yJmkAbLgAtovIJBOstUQ57XzecmnFcbhEIctDeDYWp7 FhXYJsrvTFuOiJqEmnGgNR9xb6GgQ5QD6BkobUjPS0cYJsjLCNw9X7UHL+CYKATKiNDY YeFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iwYgwiGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si1174161eda.198.2021.06.08.19.57.16; Tue, 08 Jun 2021 19:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iwYgwiGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233144AbhFHOC4 (ORCPT + 99 others); Tue, 8 Jun 2021 10:02:56 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:57516 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbhFHOCz (ORCPT ); Tue, 8 Jun 2021 10:02:55 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 857371FD33; Tue, 8 Jun 2021 14:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1623160861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CF3V2yBluejgpXrXpzIa28hHGX5nHnF0ElTMo/4V698=; b=iwYgwiGyiwgv35j87q2CCzyEWZb8OUvJx5l6BRtuTRjlI2w/JHZc/w6A7VeuaPOTdo9Dqv JXmvKZimUF99jZffOp66kjYcq+NfHy8jTFdU+vD0GNx2HmDXbOiuOPl69gIR+kHpIqSRh8 vlaZSYyaHJHgPxyEzhKH4YunXBOw1qM= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 889E4A3B8A; Tue, 8 Jun 2021 14:01:00 +0000 (UTC) Date: Tue, 8 Jun 2021 16:01:00 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Anshuman Khandual , Dave Hansen , Jonathan Corbet , Matthew Wilcox , Mike Kravetz , Mike Rapoport , 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-kernel@vger.kernel.org On Tue 08-06-21 15:38:54, 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: Michal Hocko Thanks! > --- > .../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 -- Michal Hocko SUSE Labs