Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5148918pxj; Wed, 9 Jun 2021 10:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb5pKbqbJU0GJeUKWWpONleOyZCJFaNc4TB5J5p85S5g5mP9vcHSVhK2pywxGJ9Fr/GdpG X-Received: by 2002:a05:6402:520f:: with SMTP id s15mr463946edd.125.1623258794543; Wed, 09 Jun 2021 10:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258794; cv=none; d=google.com; s=arc-20160816; b=QKlYLwGHYX2mfmMphPajeNXUsz/TWkEBNR799HdcwzjksegtL1/X0aGWMgI4nnXx7a e06/aM9TEvtz17XKbymVK/hNQc6fj5v6EMFMOkyjeQ0l6TTBWKmZnY3g/ykIKElqHMoH BEvTusZF493egkKRDMWVQPtVfgpx9ZkvXhx6YbDyytW0ZR9b/TgcwAUCjJABDo/u8Bhj fWoWo3ZNVxjQLY7es95hW5W006XxXiGCN/b0DlpUWZP1eGyxUoa6krGjyI+8LCWigYm7 H+pfozUxIHL0KZyOkL3LL/LlP9Z2YzvFxozrpsfiHdKhHRoRBxyobPchI8OUbDFSUQQb h5Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E1X6mDwvWEwCM4qkv2vY7/L/oZAtoLR8LCFJEbDinOo=; b=tHOobzx4uq9lmvG7jybaIMMhCJCjLJBYtdRo/jlC64g57xE+IlnlznAzgPI6zF5uu7 mLYAra1JUgcdVd333dgb0IUsulsq7IFZtiSxB1JXv2UrFrt50xGx6M3tzSL9XdhtE5uh dhgAsKcKdCKb5/L31HErUjzgfk25Z8MtiLaxQ8jPfoAdd74uaotV0IpT4IvPbM2IWb05 e54M1juh7Xhzh4U1iIrTMxfVMLEkUe2+ALfSBL9llDsawF27myL27O4WcnmH4VONNwXE IME2+g9a6UESkkgv3E+4KMUNmua7HCR+rIr0A4WduMWCmD/2OF232HKNQghklF5Rj4JP xLmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="B7/fWF+X"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si209951edr.261.2021.06.09.10.12.50; Wed, 09 Jun 2021 10:13:14 -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=@redhat.com header.s=mimecast20190719 header.b="B7/fWF+X"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237378AbhFIIAN (ORCPT + 99 others); Wed, 9 Jun 2021 04:00:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58275 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237379AbhFIIAI (ORCPT ); Wed, 9 Jun 2021 04:00:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623225487; 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=B7/fWF+X1mBJ0ck1F6MX3UGKduEK2I33k/dHlowUb4UQirVEiUeVsgsycN8hkRylWQzrld FognXDczYJNpvIiyNSNV8pTCMLfNJV9aMe5QMIIOhIdRGnUpReCTwGvDOeh1ZOZ4IbubR9 YsIsq4T3zVGuc4DGmMd+JtzfrHi18zM= 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-386-3ZvitKbGOrGOoA5nG_hdbw-1; Wed, 09 Jun 2021 03:58:06 -0400 X-MC-Unique: 3ZvitKbGOrGOoA5nG_hdbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6747136278; Wed, 9 Jun 2021 07:58:04 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-217.ams2.redhat.com [10.36.114.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7712319C45; Wed, 9 Jun 2021 07:58:00 +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 v3 1/2] memory-hotplug.rst: remove locking details from admin-guide Date: Wed, 9 Jun 2021 09:57:51 +0200 Message-Id: <20210609075752.4596-2-david@redhat.com> In-Reply-To: <20210609075752.4596-1-david@redhat.com> References: <20210609075752.4596-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/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