Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1892142pxb; Thu, 4 Nov 2021 10:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxIaOE4MxElz0qXdImhEG6xvcC08fhR5e2B7v4Xj1EfufJJEAe0y7Hg4fsIGk7WB8okGFN X-Received: by 2002:a05:6402:2756:: with SMTP id z22mr33063530edd.88.1636046018736; Thu, 04 Nov 2021 10:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636046018; cv=none; d=google.com; s=arc-20160816; b=p9LNm0o69b4e1sSsHF7yrv6STVSzh5IlOh277w7soS3sXnM3sdvIxW1R7gJsjznZjj O+GDd9xpWqO31MOtQpxYFdOr4gEfrUTW/wjhfWix1E28Pz1WnRayNNL/8D+uOxG14DPY S/q6/tOm7grF078PXhVDTcBm5t+WCAfmDvvjXAf0aS8vkSMbnt5N2zqhczMLEwW0aD8i kbfH/lv8yZmGz6jFoOew7Uxv42lBJIF2jJCkn/qoAmsSS7WoyOkTROnp6SFQopOrDFkG FPH+GIAGuIvJ2Dudz4DmWypWVY+RNMBji9wUeh7oywZgrWkxNuFEhpgov2NVkqnBRuGB 53CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eIdAKVGvDiz7S21vfsZfNX/HjQfNdvj7KzU/69Bh2jM=; b=xE74xaLVbGu0YY4D6whr6lV1PNKOG4ARA/e+Y6J6ZkEMHvK4GkVlUDa+BqAyvJwpFn lBDxjlOPqEZNkrKwIxFFIxZR9+DgbN7V+FgbPl+Rrr6rGGvhDW2a6moiAriqnFd4PySy rFySLyjvvD0RtxsBCDVrq/D2MtzOIlJgOVmz95IJ45mHbLV0H1vUgguLU4t5h1sZsmtW eKYVJx2pN8CmQz00m5AjP3fcch0o/Zb9Jyq5+FHxq6z1BcyNUCvcYI58F2s+sovFq64p WvbbYVZQjSRsTFDS2ZJ/xzo0hjSmcFTIGLAzajmqYIO8JTmZd8raDRaJxm+9/BvgmJMA oFaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="YJJUFo/p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si8644535edw.157.2021.11.04.10.13.07; Thu, 04 Nov 2021 10:13:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="YJJUFo/p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbhKDRLl (ORCPT + 99 others); Thu, 4 Nov 2021 13:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbhKDRLk (ORCPT ); Thu, 4 Nov 2021 13:11:40 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA19C061714 for ; Thu, 4 Nov 2021 10:09:02 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id u11so13388407lfs.1 for ; Thu, 04 Nov 2021 10:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eIdAKVGvDiz7S21vfsZfNX/HjQfNdvj7KzU/69Bh2jM=; b=YJJUFo/pYbi0ApIjofC6647X/sUNI5FRCh6UJbMkjE5h8XXM1AhQjQYKLgYPRgN4Lc MPT75ZOlo0V8rhSGLZ9F6uoYgRTcZci9kRJdTy9PE2rFwjIu1RtHkx4a3cO71A3mwEkd PFsGITNC4DKMJNL7hteWPDG+xShQw0MmY/LgY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eIdAKVGvDiz7S21vfsZfNX/HjQfNdvj7KzU/69Bh2jM=; b=viU1ty7cgpYM26zsDb3oc7NbAxWgDi0daVM86XqLxWAhZpEqGQEA6xjB2zaUNOojB2 kvbstu15z161KPyTMb/DxlUWu65zx4I0Zv//sRx+oGd0AiaMSy8f5gBTD1V/tHh7xnb+ SMTLm3WLK8eay+GmO/4QMYwiKSWydwCzBwWeQxNnLyrSRuTrKVWO1ONCaYJ3AI7KO4P7 IKVwvgJ/mHANvYO9oc4EqhBACez83peRD6wDLZdnfeHspFSrPCVlrJ2sqsCG+H9jW7Pp SuDcoGnHCvPUGTaNBcqXbrfBy2CGHCasjMSyVPMNo/HpOzFxREGvMFj31xGAk6G83dog oYrg== X-Gm-Message-State: AOAM531ruOEikt1op75c9MxuSUvVAoOMu/YuDX7OFZ4uq74jvFxuAIKQ srE92GWb4YghR9NNYUVyNrfqH8n4WWwr9CDN X-Received: by 2002:a05:6512:74b:: with SMTP id c11mr34815425lfs.615.1636045740000; Thu, 04 Nov 2021 10:09:00 -0700 (PDT) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com. [209.85.208.178]) by smtp.gmail.com with ESMTPSA id q16sm140570lfu.40.2021.11.04.10.08.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 10:08:57 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id r10so9467774ljj.11 for ; Thu, 04 Nov 2021 10:08:56 -0700 (PDT) X-Received: by 2002:a2e:a7d3:: with SMTP id x19mr27547940ljp.68.1636045736293; Thu, 04 Nov 2021 10:08:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Thu, 4 Nov 2021 10:08:40 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: flush_dcache_page vs kunmap_local To: Catalin Marinas Cc: Matthew Wilcox , Christoph Hellwig , linux-arch , Ira Weiny , Andrew Morton , Linux Kernel Mailing List , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 4, 2021 at 9:54 AM Catalin Marinas wrote: > > We do. flush_dcache_page() is not just about virtual caches. On arm32/64 > (and powerpc), even with PIPT-like caches, we use it to flag a page's > D-cache as no longer clean. Subsequently in set_pte_at(), if the mapping > is executable, we do the cache maintenance to ensure the I and D caches > are coherent with each other. Ugh,. ok, so we have two very different use-cases for that function. Perhaps more importantly, they have hugely different semantics. For you, it's about pages that can be mapped executable, so it's only relevant for mappable pages. For the traditional broken pure virtual cache case, it's not about user mappings at all, it's about any data structure that we might have in highmem. Of course, I think we got rid of most of the other uses of highmem, and we no longer put any "normal" kernel data in highmem pages. There used to be patches that did inodes and things like that in highmem, and they actually depended on the "cache the virtual address so that it's always the same" behavior. > I wouldn't add this call to kmap/kunmap_local(), it would be a slight > unnecessary overhead (we had a customer complaining about kmap_atomic() > breaking write-streaming, I think the new kmap_local() solved this > problem, if in the right context). kmap_local() ends up being (I think) fundamentally broken for virtual cache coherency anyway, because two different CPU's can see two different virtual addresses at the same time for the same page (in ways that the old kmap interfaces could not). So maybe the answer is "let's forget about the old virtual cache coherence issue, and make it purely about the I$ mapping case". At that point, kmap is irrelevant from a virtual address standpoint and so it doesn't make much sense to fliush on kunmap - but anybody who writes to a page still needs that flush_dcache_page() thing. Linus