Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp482523ybl; Tue, 28 Jan 2020 06:39:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwUOKXcQuh48CqLlE6TqmxP/WQqp0HJhvG4o00/hl3O2xRjg3HR3ejamOfSMnJVbHnC1/0K X-Received: by 2002:aca:c646:: with SMTP id w67mr2924835oif.171.1580222342641; Tue, 28 Jan 2020 06:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222342; cv=none; d=google.com; s=arc-20160816; b=CPTqHmzOmPbz+ZMDrqBZN/mojHPn3YnUwpNBk2x/hZRBunVpLm3wVAxcskZrCHLep3 i9Ru9yVQ8OXg+VP1rxL4P/hubvgSJbeKSlrQYtgjG97tyUyp/RNVucKSe0JGK/TpzYFd LgrblJkodn2P+0ML5EAzL7uBWpwIq2nFYCcanWbnZ+XXTT/FruYmxSnw5FcLSsQAucXl cSXZsuDStIbp5mj+NjDs6Q8kK1+uExXFVXNFyRXyjLN0AHtF/G/z83ScQ6rGuqH+Ph08 j/13cAsFsawUYC4fz1uIlLGiofErfG/OpVMIKbsqkumPvHx69wz67VhXJlJzuB/hq78k 25Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LCgmb3vNjW6Xx/yxNXuiTOTAhrFmmF5IwnHVFaoqA8Y=; b=ntoRpJqRJyJ4CFSwuc+gHKJYpUQHLYW1yhcqdPm9z6V+eBvr3aBD9KY9YgYN9QG11o e8T/utsYxfZQMQXkeLx2fyiQxrWMCFx3O17d5HJFna6VHqdFfprWmkJX5Nmx1u0VNsBl Guf4kZpNmKD6qoD8WflUPTcT3bXYDKAmR26ilby8+SRWKeOAZmEk3ZqyV0qPSBSfoKZt vYRfwbabTKoSLfjV2bLz9XLGtyLnD0p39B69EyOVKQmrKccY0qzeCqwYosL0S5JHBLwq aQQuAsj/jWOvw3wQcNIVNyhteGEjcjnX8ja5JaWH0QelNbqW0BRPgiEQVuevDLQp+H3t WWoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=idv6L3Jw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m82si5075083oig.129.2020.01.28.06.38.50; Tue, 28 Jan 2020 06:39:02 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=idv6L3Jw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731625AbgA1OWf (ORCPT + 99 others); Tue, 28 Jan 2020 09:22:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:48376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731591AbgA1OWb (ORCPT ); Tue, 28 Jan 2020 09:22:31 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E57824681; Tue, 28 Jan 2020 14:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221350; bh=a3b8GTGMrmfY7nhd+ivfJZYIfMPdm75bJRxBWlYuFWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=idv6L3JwQXi76ldqVNeW6zGHbrpjTgj7uE/TMYnyUcgJ892uLAefKF3Eryve2j5K9 QLMAZ70Cto8ILdHpp/gus0Vn12iUF0mMzGTWET9tOiUwxAmkSxkG6xc41UqYIhUmvQ AP8MYTqKhBuDlOfiG2ZYDTVFXHbPViTrsVAAvEwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Lynch , "Gautham R. Shenoy" , Michael Ellerman , Sasha Levin Subject: [PATCH 4.9 153/271] powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild Date: Tue, 28 Jan 2020 15:05:02 +0100 Message-Id: <20200128135903.952405935@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Lynch [ Upstream commit d4aa219a074a5abaf95a756b9f0d190b5c03a945 ] Allow external callers to force the cacheinfo code to release all its references to cache nodes, e.g. before processing device tree updates post-migration, and to rebuild the hierarchy afterward. CPU online/offline must be blocked by callers; enforce this. Fixes: 410bccf97881 ("powerpc/pseries: Partition migration in the kernel") Signed-off-by: Nathan Lynch Reviewed-by: Gautham R. Shenoy Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/cacheinfo.c | 21 +++++++++++++++++++++ arch/powerpc/kernel/cacheinfo.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c index c641983bbdd68..0122d5ce0637d 100644 --- a/arch/powerpc/kernel/cacheinfo.c +++ b/arch/powerpc/kernel/cacheinfo.c @@ -867,4 +867,25 @@ void cacheinfo_cpu_offline(unsigned int cpu_id) if (cache) cache_cpu_clear(cache, cpu_id); } + +void cacheinfo_teardown(void) +{ + unsigned int cpu; + + lockdep_assert_cpus_held(); + + for_each_online_cpu(cpu) + cacheinfo_cpu_offline(cpu); +} + +void cacheinfo_rebuild(void) +{ + unsigned int cpu; + + lockdep_assert_cpus_held(); + + for_each_online_cpu(cpu) + cacheinfo_cpu_online(cpu); +} + #endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */ diff --git a/arch/powerpc/kernel/cacheinfo.h b/arch/powerpc/kernel/cacheinfo.h index a7b74d36acd71..2cdee87a482c5 100644 --- a/arch/powerpc/kernel/cacheinfo.h +++ b/arch/powerpc/kernel/cacheinfo.h @@ -5,4 +5,8 @@ extern void cacheinfo_cpu_online(unsigned int cpu_id); extern void cacheinfo_cpu_offline(unsigned int cpu_id); +/* Allow migration/suspend to tear down and rebuild the hierarchy. */ +extern void cacheinfo_teardown(void); +extern void cacheinfo_rebuild(void); + #endif /* _PPC_CACHEINFO_H */ -- 2.20.1