From patchwork Tue Aug 21 10:44:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10571365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CFC21575 for ; Tue, 21 Aug 2018 10:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 338B629DA1 for ; Tue, 21 Aug 2018 10:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2805929DA4; Tue, 21 Aug 2018 10:44:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C12D29DA1 for ; Tue, 21 Aug 2018 10:44:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34D7D6B1E4F; Tue, 21 Aug 2018 06:44:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 289426B1E50; Tue, 21 Aug 2018 06:44:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 102066B1E51; Tue, 21 Aug 2018 06:44:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id D31686B1E4F for ; Tue, 21 Aug 2018 06:44:52 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id j9-v6so15842745qtn.22 for ; Tue, 21 Aug 2018 03:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=WZ73kplE7i691B4mAUaTbKLaXH7FOEpXaE1Zfovmct0=; b=aZPIi9QWbkLmxpEnu/QIiw05iQPF8QkwEUPIf8DJFFAquXfZb3ycm9mEs1JlQ8WwrJ YdoyNZ95ulnohjNXuWSpF93vZbiAyIuYLzAOw1yoxTbSEh+NqXKx/GnbPyoYN1RZQluF wm4CB3IuTALB+Nyv/y+BV6zUbb0QBdRzlGzPHrfaeA0MVFOlOzjkmFpJRCjH0lh2xLz+ Dhou7BgHIUkAJYhknwwZ2YcOjisppa7qKJ46ZQDkcH7tFOuqzI++haPFfUSATCJYC7Ml gGMZl7qncP6+JhS1LBnC/u7+/E7QRGaQQCSmgBV0hIUVm7EC6A6HVUJeYdqrAhjYiQzE bqww== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APzg51AtP1QR/TY+VTOHtPfj2mI/Fogygfm6m2t4hJztIKoD+eS5sRn+ Pual27YanbfA1W8Wdn5RZ/Ke8OY7cBjZC19b6lK570cPyjYblqXBdEN9t8RA8JZh3OB+9yO9Zoh hWR/N2EibXbFoIRMrMa+g/ctU/byRzP0ceInjJmyEXp1uupPTat76oYgGtBc69kliig== X-Received: by 2002:a37:119e:: with SMTP id 30-v6mr69272qkr.136.1534848292660; Tue, 21 Aug 2018 03:44:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxR38tmVRY8G6y5+UUPfHwxVMpqXAhCLug5x5avUaZBVyI88B1M4bAyXlckeVn6ZAZX7gO X-Received: by 2002:a37:119e:: with SMTP id 30-v6mr69254qkr.136.1534848292134; Tue, 21 Aug 2018 03:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534848292; cv=none; d=google.com; s=arc-20160816; b=skXKefJ94/lMg06E81y55hUUtK9e6rwDEn3yeI69G3TV1Y6uVUL+/hl8kL2f25+EsI JbDSpblt+lFV//9Ryr88BpYHoFTfx+3wcVz8IWsDR3tzPkj8dzdOxcHo4LHVxlKas4sL fXZvyvEfXYyV62kjDrpqcNhWGE445ChIws7PxxzcV1LcZazhZW5xQMVUyVtakFk16P3p g5kITkn9rs1OI/n6J4+rOkbI6+psDbAdTywZBTchWlkz3+5eJaRhMIpStx6hqtW3lAEr quQrsfsodnVL7gtQG8iZ+PGhI7p+yEPp8VpJaDsuNXUTL4U2WayMjvrJz41n5Pzkehbx NqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WZ73kplE7i691B4mAUaTbKLaXH7FOEpXaE1Zfovmct0=; b=A4qlWVrCnfE2y/KOTruqTT/uy0QcuBzMrH8GrepTr0OzUsNzwJPI0KgI5NIjEijr5L rONWFBqHIq5iuNNftYlCOw37ktppWAq2fxKf0Z6hLEW1bRROtVktYN4xtOuVPoClJLgg 4+xMoEndHkOsUPb0z0ZowHh2CD/jStpXvgoZke1ZTnAc+A9tMkoIIeYc9kqGGE9RhMLv EK7l6b3LsMdB59d3xCAy+WLCOpMFZ3qpD/a0GBKogNWAArk/YQEh1Ul/IOjEeHMsPV4f z8OghoAdzGmhFbzu1x4FDTHa2lTWg5+ugjOmiq4ejdcQ7303JOFSYphzoeYy31rNagNU j2hA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id l62-v6si4390933qkb.0.2018.08.21.03.44.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 03:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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:'' 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Pavel Tatashin --- 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; }