From patchwork Fri Jul 12 17:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Jackman X-Patchwork-Id: 13732002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4214DC3DA45 for ; Fri, 12 Jul 2024 17:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE39C6B00B2; Fri, 12 Jul 2024 13:01:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6A0A6B00B4; Fri, 12 Jul 2024 13:01:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C3E6B00B5; Fri, 12 Jul 2024 13:01:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9B1016B00B2 for ; Fri, 12 Jul 2024 13:01:51 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5CD3180BE3 for ; Fri, 12 Jul 2024 17:01:51 +0000 (UTC) X-FDA: 82331717622.18.F175EB9 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf15.hostedemail.com (Postfix) with ESMTP id 6A04DA0036 for ; Fri, 12 Jul 2024 17:01:48 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="3IU/E2X1"; spf=pass (imf15.hostedemail.com: domain of 3e2GRZggKCL4negoqerfksskpi.gsqpmry1-qqozego.svk@flex--jackmanb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3e2GRZggKCL4negoqerfksskpi.gsqpmry1-qqozego.svk@flex--jackmanb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720803673; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L6MmdIw12rXfqeUQQj88z73bFenIU6DgFXoL45UzNnM=; b=YngaRiTsrNSk3czKXzDDF8VHUcNHBh/KzHsEFM3LhpJHcU2T+cuYN4BNYfvYMPQvC9SLVK e/AwoPL69tE6ai5SNo4IGuc3lnRXq750wGjumqaQTXemA+xZlAMh9BLyoGBjLSmzTtZqR7 WEvh3in5PQRQNMOzpjuzgeFr34jI8Qs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720803673; a=rsa-sha256; cv=none; b=TSvlaXW7hNgZP19Kbx0Nm6gUwNbu0h2z7InD2n9a6fQfFWrUwLgOBdWDgbqgBLsfxI4RdR hf9ogMnQAJ2aIzp7u8vU4+lubOi9zboV+9PLgB9hfdww82pR5KgA7pAtjv8t7YdRIBRpRE LGFmvWYfbupCnXxtv0dQEZGGc9V/668= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="3IU/E2X1"; spf=pass (imf15.hostedemail.com: domain of 3e2GRZggKCL4negoqerfksskpi.gsqpmry1-qqozego.svk@flex--jackmanb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3e2GRZggKCL4negoqerfksskpi.gsqpmry1-qqozego.svk@flex--jackmanb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e039b77a040so3804153276.2 for ; Fri, 12 Jul 2024 10:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720803707; x=1721408507; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=L6MmdIw12rXfqeUQQj88z73bFenIU6DgFXoL45UzNnM=; b=3IU/E2X1tCYquSqpMfgAJPAfiCqt5eRgk0S86C75awrzryI22d4OMDdxwucdtaYRgN ShFvO76q+3mgc5KtvxZPBmElonyqC4CYeB3NhevtQjS7a2PijF+NNis7s0ZEuHuqI+R0 Znd5vrIDby89VhBMsb8jzwMymYl8CfASIXs+0PQMXVp4/bksXF7ntCByAxOJaWcxTO6d +z0Qj9UnA7njMpfqzMD397MA6AXnxSSd6JU55IXQLdGdzoJjz0qjFJXGXxj4TVcNpf79 FC2fh6QjSLrMU/ForjBRtjaozEvbfUfbb1uK50XbBzYJoLmyilH8tz6lfLysw5rwA/JX SfjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720803707; x=1721408507; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L6MmdIw12rXfqeUQQj88z73bFenIU6DgFXoL45UzNnM=; b=jOMaxTJwtrwubIZJbTKQn6vTZCHNDxVp+DcCnvgxzgJYHNzKUfLD42JaYKuIU/Qov9 PwfvtRwvlUbNwN5vuto9JtJtuMY503Nu2oPy7bT/vPWd6oOpDAOoyyZo9DIjY9AGrv4F SLiVwp2NqKkAPSPB8wVYKi8hEFPy3v1sbJkQTw2kPj8x2xWwsxRPXvctptEvQv5zvCeU hnrXNXNlBthudw3NASY3uXii423Mqe8lAShtTpYAjVLJv4nFUH8Icx1yrn4BN4dPfIry fbaVfL2bjR0itqRcRX2dxHGiPbIJXP+AdOAXvBCADED/06VSQtmSH2G1aTnWnb0qN0oU foyg== X-Forwarded-Encrypted: i=1; AJvYcCU55KNyu/p/0dNVnOFDkPhfxEP5Jb/2cLzSJ59zdgFmSGRm2ORgbKO5SEWVeYm/5yTlNAo/M3N/o7VRBM4Ey7BSXdk= X-Gm-Message-State: AOJu0YyOpiHnre0Bd+qe8g4ygfkfGXigpzVexROflTSo2nX/T5CRfg3s FyIl874/IaPUVEuK6EYZMXANNv1YCvu/ciqULcDAbj+99lBwPS4HITOa8zh0wfTC53QWkzOBlpT 2GjxRi8Tafw== X-Google-Smtp-Source: AGHT+IE68Lhuxh26ghjRhhLaHrJ9YduMOpsYsuWnIFTPqHiwg/OIUXbqUWhmNqr8FCCI3K44ay3Zr7IW+9N5Rw== X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:a05:6902:2e0d:b0:e03:2f90:e81d with SMTP id 3f1490d57ef6-e041b14c989mr757806276.11.1720803707241; Fri, 12 Jul 2024 10:01:47 -0700 (PDT) Date: Fri, 12 Jul 2024 17:00:37 +0000 In-Reply-To: <20240712-asi-rfc-24-v1-0-144b319a40d8@google.com> Mime-Version: 1.0 References: <20240712-asi-rfc-24-v1-0-144b319a40d8@google.com> X-Mailer: b4 0.14-dev Message-ID: <20240712-asi-rfc-24-v1-19-144b319a40d8@google.com> Subject: [PATCH 19/26] percpu: clean up all mappings when pcpu_map_pages() fails From: Brendan Jackman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Sean Christopherson , Paolo Bonzini , Alexandre Chartre , Liran Alon , Jan Setje-Eilers , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Mel Gorman , Lorenzo Stoakes , David Hildenbrand , Vlastimil Babka , Michal Hocko , Khalid Aziz , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , Paul Turner , Reiji Watanabe , Junaid Shahid , Ofir Weisse , Yosry Ahmed , Patrick Bellasi , KP Singh , Alexandra Sandulescu , Matteo Rizzo , Jann Horn Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, Brendan Jackman , Dennis Zhou X-Stat-Signature: uwa98cua3ts9i7mfmeuaqdsj4oqbyttc X-Rspamd-Queue-Id: 6A04DA0036 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1720803708-402162 X-HE-Meta: U2FsdGVkX19njWNfD+Jvf+EhIMa615d8M8ImxaDp4m7GLcwJ6o6XnmFC93uWYXohFoqe0PsokOJhCJkFKN9fMMlKHY9k3Q9q7bnzOMdQOmTZbg1M8S5zlK0jfnQv3OgWFuApg3HdUqeL7dBFSPJFHybZ6aGBpPU5Ow8/9e+YBI0wEchYOfb1fJorqStktwY38qksfaABMQlPr9Y9ADnpIN9SB8y4UX6inrVFKaq5SEGzoFsZwOjiDPiMhylOKkdeW2VIZj2dRdVXCOaGBTwMmFLFVCdjITw6cKEKSYQNcqWUf0hrWh22OyXMHe0+Kt8wHqXQYsuvoMtiXXLK84WaNwr67dpmuth5A0giMcXnC94cyB0SUbRCYXqzzDWUBXnpYstjOInDkDjde6advKyrbUqRkuVQAon2bhsgHG7KZF69HphwW3NrNS1oH+Htm/w7pXUtXLnEA3xBYlOKBmTiT1cqO83x8ilYNIB7XuaQhRCMbhhddQD9Ro4Mq94mqWco+BFob9JboxmRGUUxjbd/OL72Kq/efhXqwT+1sjr5sdSuKsOqF7I0xj+Q4C4usutBYBQODPjZw8HJSk0Xkhc+tuf2nw4DQjTCmPdKr2ldXQOZ0I6jTD3oDw7wudTq3WzQt6JpeXXLU7L/zOFKBtgBDQZKrJE3dk7bFhnKQc1s9Hjb7h2nnvSdpzdjAF/KsgDD2rYLOlKTFBz2d8REezmXy4aOszcz56j8hnwBzpYUQFkVRcYykh4JFiqOVWFPDxc5pjdTmp2KN3Ijyth2+mEU5+twRZ7mMjljYSejUdWds9hPMksqz1s5lokScKl01Ulgo9XNFHVbjW1INeMM2mMTPzrlnklqw0FEaUpfJXvENjJWXMu+ec0Dh2Ye/3JqPrwln5UVuDMCn4JQgGQ3hHjxcMNqEj6mMaQfORxb/LNbjD3sRyCM82llaUb0+v1PkiHs7MaU2qyDL77jUUguGLh uDG57XEb YF4JnOBH/skjOOsnSvZO3ukNNS3/NjCeAQ6jfAqREV9JaAmpbG34LUOlA3GWF4EyCM24Zirgr+pr8yhr0KSdot+pL34MrGp2cInax2RFcwkcTPon+XRiSgQUyYnZC0PVgVQbdZq8ljoZHVnLQHCMRdrEa7ER/q933icnwHqkzbiUJemZx0v5V0+YoqIooOfhfoMarRCO+UlnbeHGSLw5AbbCbkUgzoz7Zi0zL+FSyqzV/ny39SuQ8GCyrti4oIsbre/1ivIYrG5rwhXsVZZL1xp5b/fXkHOXQ3HPFdYzpb9vtFWx51kliimzaPOc5/C6VZSspp84VY0Wo0r3d21jecmRBd5bYXtUbhKdU5ej5HDh0tMWpOjpnds0qWEQIJNzyUURNB6qwk5X8AxyecjGRjP7CqO0RRmEY4JXTI1kwVHhn/CH1iswR359i6LF2QzjIwhNue3Kgi6MmIUsYAvcC5Ql7oeD6YF8uQgyXHHrn8SAHito5qz10C6BTNHuED6meklSO/kMCD4f3RQCsDQN1T5OcuHM7K/+VfN5S/KqEgzb4voX+XDjiJ7JDWM5aE8Y8z5upawmFd2t3rqv2MUNjgYPPnLkWJmR4J38GFaQiwCcjq2JeTqZ6n2EPeQA/UZcefKOi 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: List-Subscribe: List-Unsubscribe: From: Yosry Ahmed In pcpu_map_pages(), if __pcpu_map_pages() fails on a CPU, we call __pcpu_unmap_pages() to clean up mappings on all CPUs where mappings were created, but not on the CPU where __pcpu_map_pages() fails. __pcpu_map_pages() and __pcpu_unmap_pages() are wrappers around vmap_pages_range_noflush() and vunmap_range_noflush(). All other callers of vmap_pages_range_noflush() call vunmap_range_noflush() when mapping fails, except pcpu_map_pages(). The reason could be that partial mappings may be left behind from a failed mapping attempt. Call __pcpu_unmap_pages() for the failed CPU as well in pcpu_map_pages(). This was found by code inspection, no failures or bugs were observed. Signed-off-by: Yosry Ahmed Acked-by: Dennis Zhou (am from https://lore.kernel.org/lkml/20240311194346.2291333-1-yosryahmed@google.com/) --- mm/percpu-vm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c index 2054c9213c43..cd69caf6aa8d 100644 --- a/mm/percpu-vm.c +++ b/mm/percpu-vm.c @@ -231,10 +231,10 @@ static int pcpu_map_pages(struct pcpu_chunk *chunk, return 0; err: for_each_possible_cpu(tcpu) { - if (tcpu == cpu) - break; __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start), page_end - page_start); + if (tcpu == cpu) + break; } pcpu_post_unmap_tlb_flush(chunk, page_start, page_end); return err;