From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8A2D3B71A6 for ; Sun, 9 Aug 2026 08:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786265734; cv=none; b=F6XdoQN5QhAbl1dJNTgtnt9l3SBgPUx9jNi5giqS8bfu64zlvunvdXEqGCU0uZw5ozoS+CgZnZIwLmQ6iiH0CZ3thIE2mNSCpfoWNMuahH/98/C+CUOdi1K/odODVBc5gvXVBFTmCMvnOyiQGfiLBlmrtgZBMdQBYitvyJbFDbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786265734; c=relaxed/simple; bh=XJ13sZxBIJ6krRBf+heB4Ni/k1z+s8+IsLQT7eImPz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=muXRduyTn8F1wDjS6ms7/s/PTqb6IileQ9fFxBqbq/7NCfRdUO/JOGUEq0YYjOz3hPFjamVNkUQ7ny9Pj108bFpCIVfUrfnG/LQAsnYbRLoX3NCV6YbJ5lU3ucB8kMdIP02K3qxPJQYofGTmaaB4FaxPre9lvflW2L4qfrc2OOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e1PF3dSc; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e1PF3dSc" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-6a156627e22so4885900a12.1 for ; Sun, 09 Aug 2026 01:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786265731; x=1786870531; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ApQfFv154paetM9TgIxQj41acxDPs1l/KeCboEHJf9A=; b=e1PF3dScL8aEvRZaPq6bnJvKfkXtuWLvhUpzYMfBcunM/oVLwPRGorm8OSL9KNhH1u NY0o5HTc/uCyklcOr9HmxFkcCditPBIbqA63iF/F7kHM020USljw14b8FLntjPk6Zl8z w/O/gubdkTVhWqdNZci04jl+g4WXnG7gYAFkgTh96BTt11Sa3quOzRSYLPkqtLTMuBEI H8Qe/TI4iNEvLfFL82mioaJWMQjnCYak+5mmyWUHL6LNcVdu3HbBG8jN0DLf37Lk8nv9 Dr+NKWxazAj4HOu/6VHwYuuBIgADL7B46vX/PExUVTuR/+n+kwTBIYU49LVMLPW1rh6I Qudw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786265731; x=1786870531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ApQfFv154paetM9TgIxQj41acxDPs1l/KeCboEHJf9A=; b=ba1tZ3TGYpPVyg7JaKTXsrqlDPf+/uYiL0MGr2nUsiIYkUcfWyUc8HQWLtmQj/VDaV 4p4tdI/wQRAt+V9D9b5eGiVDqp7vX0NG1CKe/HlZ4eGcQXQyPcRxcnoax7nOwuorCUKC vZ/Mvl686yGiL8jGAcMV+68Sj00hanKO9CiNYfGkHglWs5xaxlqOWyp8Dww+U5gOcvHV vK56qkpaJlhzUIuI7kDtbtvqZTDu2VKAuNHcmpSj0BxpEuJ0/mfz9hOrxzhRoKXEe0nH W1VQKO9HC6upiJcADplN8Bs7S4xLQSp41l9gAJMuEZHGnPlM03+0ngMPPc078zTLahXR 9FVQ== X-Forwarded-Encrypted: i=1; AHgh+RqvK/SnNQQyFKYwgS9l2MXQQLIl09P3WHOfcLvyqYJrHrefj+qBcwqT2Cm81mUnBMHciiCAS49tSGgIxDM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxgh2qozFL4PNxYBVDKxQSj2uJCQ5PRJo//NBJtR+5T1FwEbeVy GxZ407C9kdkxtILgRz3j3ltgGjEgNeJfHDgYip3/1EzMjt2k+Yva+e6T X-Gm-Gg: AR+sD13eNZKtUeSRA9E6U9LhglExev3Hb+miMA8++5z9pvKalm6/bFiW+bo87fV1Vkb Ic4uvc8cUtndXCl7MiOTqkbm6hg5vXo0Qa4iz80c+jBUQxoHbE89LD/lYnA0DbnhR2mLQvlauKI w/7WAyFYU33sB/Hqc0h0EO9kXgOv/CMsnT6Wc3238xEjJ7EDFUSetPjuC2A0XL+M9QIqv0wM6JS GlUG9TV/vL5PaGDa36N3rReMS4wch1KIOtOjhnsQfWphJZkEs1RnvsRIgf/y8lLe2q0eqecb5WI VSzNdX8m36LEKhKFx8fwUC6gyBCxWwvorqp4poJFOko95P+phb1qL+76X8Ci5pio145eWVPvQ1b XaG1oDnsOjRReEAJPUzhsitZYACXGvomdzUgksdOA0tTbwLcWulennFyHSmFO/nmCjsmjf4wDbT aLvWzY4VWZyO3h9a+NtMsz6dryDk+cjQ/68iwOTaeiFyTgZ67xFnqb3nfLEdE2v+vYaO9zNalno a1ryAimVXYYeH1d5lzd0vLLBHZ0IdQ= X-Received: by 2002:a17:907:ea8a:b0:c12:49d6:3c5b with SMTP id a640c23a62f3a-c208d3f294dmr456032766b.8.1786265730821; Sun, 09 Aug 2026 01:55:30 -0700 (PDT) Received: from buildhost.darklands.se ([2001:9b1:ff:d701:51eb:176f:63d9:53f8]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a1f630a4afsm1606681a12.3.2026.08.09.01.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2026 01:55:30 -0700 (PDT) From: Magnus Lindholm To: richard.henderson@linaro.org, mattst88@gmail.com, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org Cc: glaubitz@physik.fu-berlin.de, mcree@orcon.net.nz, ink@unseen.parts, macro@orcam.me.uk, Magnus Lindholm Subject: [PATCH 3/6] alpha: fix the local TLB invalidate in flush_tlb_page() Date: Sun, 9 Aug 2026 10:49:35 +0200 Message-ID: <20260809085208.3262799-4-linmag7@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260809085208.3262799-1-linmag7@gmail.com> References: <20260809085208.3262799-1-linmag7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit flush_tlb_page() invalidates the calling CPU itself before asking the others, and gates that on current->active_mm. For a non-executable vma that means a targeted tbi(2, addr), which acts on the context currently loaded, so as in the IPI handler it reaches nothing when only active_mm names the mm, and nothing forces the old ASN to be retired afterwards. Test current->mm instead. When no thread of the mm is current, clear mm->context[cpu] so a fresh ASN is taken at the next switch. That also covers the case where the mm is not this CPU's active_mm at all: the CPU may still hold translations for it, and smp_call_function() does not call back into the caller. Reached in practice by folio_mkclean() from the writeback flusher kworker, which has no mm of its own: about half the calls during writeback of a shared mapping, and none at all on anonymous memory. flush_tlb_mm() does not need the same active_mm to current->mm change, because its active_mm path loads a new context rather than issuing a targeted tbi(). It does have the separate caller-CPU omission when the target mm is not active_mm; that is fixed in the following patch. Signed-off-by: Magnus Lindholm --- arch/alpha/kernel/smp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index 0dfe29b59039..d167b3ba1303 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -696,7 +696,15 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) preempt_disable(); - if (mm == current->active_mm) { + /* + * As in ipi_flush_tlb_page(): the targeted tbi() reaches MM's + * translations only when a thread of MM is current, so test + * current->mm. Otherwise - lazily borrowing MM, or not running it + * at all - clear mm->context[cpu] so a fresh ASN is taken at the + * next switch. smp_call_function() below does not call back into + * this CPU, so this is the only chance to retire what it holds. + */ + if (mm == current->mm) { flush_tlb_current_page(mm, vma, addr); if (atomic_read(&mm->mm_users) <= 1) { int cpu, this_cpu = smp_processor_id(); @@ -709,6 +717,8 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) preempt_enable(); return; } + } else { + flush_tlb_other(mm); } data.vma = vma; -- 2.53.0