Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4942300imm; Tue, 21 Aug 2018 03:47:19 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx3mCp1VU+lsmG6T4jh3+9X0mmrtIcZqLmh2dasX0VZFB52lnu0rtCb4Icbn4Q+TCDGcsvq X-Received: by 2002:a62:201b:: with SMTP id g27-v6mr52785507pfg.253.1534848439656; Tue, 21 Aug 2018 03:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534848439; cv=none; d=google.com; s=arc-20160816; b=QCAJiTv0yW7NCC/90S8WWZgQ9X5Nc+FrHXjaRjUzlVIAMm5b9BWfiZgmLD6SzJxlbN Neb1NNEaLjKMEU8Yrzws7SIHS/A31Wgnsbyby9ipqNNrqjPNzzTvnxMS7ZTVjJx5ktgE 7ZOWhBHUtnfSTyTZ6uZQw2KNkCF5FLIeOTvGxDFRWWl449HWs9ex9F3mgl2c72MOI6cp oc6d/9VdiE+dFaX/ue7GFfZ/xgfEs1YBMfULN+uAKqOheeuK0jKrDz2Dj51nft3iSnrV uf64kLPS35RoLkm3LBacH4r8a9/XHgctBUncMjqyNvOfE2/RMTmXkdYANcGSBJipDZxJ xVGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WZ73kplE7i691B4mAUaTbKLaXH7FOEpXaE1Zfovmct0=; b=X2Z248WIXJdNsHrJi1vdLNhx/0F9xG/bDj1TpERDjImxK/hRXIbL3XqTFQbgr4Wjy+ dBumzfKqR+WSqBsw0z+/AfgQiFqCiZnqCPuYR5BrD5zH2X2W21xueEhP1XFwiQMtFFdu hRAblqDH77gsR9imuGW9wqcBpfJEa4zfJYu4XllCTTWiQeS+bfljwY16RwbtcoWL0zGS Q4hROCMyMygp1uSboNgMUAFU07XOn9yD+01QCiqDYeesQpzmUBfCBluRibo+DoQ3xf4c ZGPO77Gm4GBhVbL5uGeChcfIbc8ygn+MtvbTevcLZrSnbsssAxKe9/CFm25YxafrzrWo M2iA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24-v6si12957012pfk.56.2018.08.21.03.46.43; Tue, 21 Aug 2018 03:47:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727402AbeHUOEb (ORCPT + 99 others); Tue, 21 Aug 2018 10:04:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727367AbeHUOEa (ORCPT ); Tue, 21 Aug 2018 10:04:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC25C8076826; Tue, 21 Aug 2018 10:44:51 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-96.ams2.redhat.com [10.36.117.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 919A59463B; Tue, 21 Aug 2018 10:44:49 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, xen-devel@lists.xenproject.org, devel@linuxdriverproject.org, David Hildenbrand , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Rashmica Gupta , Balbir Singh , Michael Neuling Subject: [PATCH RFCv2 5/6] powerpc/powernv: hold device_hotplug_lock in memtrace_offline_pages() Date: Tue, 21 Aug 2018 12:44:17 +0200 Message-Id: <20180821104418.12710-6-david@redhat.com> In-Reply-To: <20180821104418.12710-1-david@redhat.com> References: <20180821104418.12710-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 21 Aug 2018 10:44:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 21 Aug 2018 10:44:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's perform all checking + offlining + removing under device_hotplug_lock, so nobody can mess with these devices via sysfs concurrently. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Rashmica Gupta Cc: Balbir Singh Cc: Michael Neuling Signed-off-by: David Hildenbrand --- arch/powerpc/platforms/powernv/memtrace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index ef7181d4fe68..473e59842ec5 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c @@ -74,9 +74,13 @@ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) { u64 end_pfn = start_pfn + nr_pages - 1; + lock_device_hotplug(); + if (walk_memory_range(start_pfn, end_pfn, NULL, - check_memblock_online)) + check_memblock_online)) { + unlock_device_hotplug(); return false; + } walk_memory_range(start_pfn, end_pfn, (void *)MEM_GOING_OFFLINE, change_memblock_state); @@ -84,14 +88,16 @@ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) if (offline_pages(start_pfn, nr_pages)) { walk_memory_range(start_pfn, end_pfn, (void *)MEM_ONLINE, change_memblock_state); + unlock_device_hotplug(); return false; } walk_memory_range(start_pfn, end_pfn, (void *)MEM_OFFLINE, change_memblock_state); - remove_memory(nid, start_pfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT); + __remove_memory(nid, start_pfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT); + unlock_device_hotplug(); return true; } -- 2.17.1