Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3683038pxj; Tue, 15 Jun 2021 06:30:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLrhP9VdN/Cw7fQ2ykgSA/9g/oUaX0yoJ8jKxTwpnjxgrzgmg14FX7yLhhX59hIIn7ZyUW X-Received: by 2002:a17:906:a203:: with SMTP id r3mr21345995ejy.361.1623763823101; Tue, 15 Jun 2021 06:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623763823; cv=none; d=google.com; s=arc-20160816; b=I4V7cKu2fzX0MTM++Vos1TbDMBOOiVaGOW11XaY18v9h4Kgvjaj7i+8TIovJv0enKt 8GgALNTzhoLPC8FQuWhe7NIMgvDcwIT5slqRJOeeOQNZiwSEi519F5BcGBxYpkRx1cEK Wos81gsbtXsiOW0TpbavPS4OYRyMDPt6Wkg8tpH7kHTbfJW4nXWeIwDDNqr2XiCe4Kgm 7w2OsfNbVGW+OgrtQYSLpQZC98Rm7qxhv5TGbZxhS92U8OR6JWdP2/7yPilMFX7I1CLL +9sjoAEHMXyznvX5Ij/n51O3bdvgLt/jHFiYbCyzA9tsD6jCsNg6uiJwOrEOI/dYlO4Z hh8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1X21SF/7fmwg2FrGG5ahYeKQk8ivw4suEk6vCt/uQZM=; b=0qr5nT5cyEEiTRoUcnKrqgFri3mSAdUzUXLVHktLMGZo6dINsceqdWMR3L+mE4+VDI 2cZwz1NO8iC+/tJTx1PMYbywHI7XsaeEjoAsdUWjX3yCnKdmmpuLocHOBXJry2hf2wQb U/Be3GNwsiWiZeGme+SGd/Ldnf+2L76kmuXh6W4/SayTaJd8VPk5/TgSrsfbmxcXBdxg pT1jzKDQAspkIxsNGHH5cHUJz92u6h90FwE50z3jH7CXXJM3uVDF0B0jO6h0mCADbtNv 7qZzBrGPx7HwdE6g47TXT4h2eh+KyUO5lQ/469tu4AjU8AFB82AcjWlvpZenuoGHP2j8 WHvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Yvjhr/bJ"; 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 x9si16915316eje.656.2021.06.15.06.29.59; Tue, 15 Jun 2021 06:30:23 -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=@infradead.org header.s=casper.20170209 header.b="Yvjhr/bJ"; 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 S230450AbhFON2N (ORCPT + 99 others); Tue, 15 Jun 2021 09:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbhFON2H (ORCPT ); Tue, 15 Jun 2021 09:28:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2E11C061574; Tue, 15 Jun 2021 06:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1X21SF/7fmwg2FrGG5ahYeKQk8ivw4suEk6vCt/uQZM=; b=Yvjhr/bJmyJ/QCD+GCduqR8jqD RfTnBcPS7gxLwW7kxITRtCz0LU2jOF9jpt0JwCS1WO3/TpTYsfE0R4dPtZGTRx/ju2FqDrozih8Jk aiZGKwiuEcyhdyeL+PmvjvkV5PFLRvauaMoSuuu9uM+vJl3qs/9CTh7sD2QjB2KjfOb65mtU2myUn qkfsk6YjZlAK3U/zrVA/R5JbS2FbFJIRHZFLKMBJGzz6h8RCblaDBYsnT/foXESa+zQPlmJelf4oX Vi9UPEtaewyVKmdkil7ItuM/Sw7khkyPbd4o6gm/aAiy9bj/1GtYW24JZAJ9XsVUcVZw0mxAa3egy OVadjXDg==; Received: from [2001:4bb8:19b:fdce:9045:1e63:20f0:ca9] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt942-006nuT-C1; Tue, 15 Jun 2021 13:25:13 +0000 From: Christoph Hellwig To: Jens Axboe , Thomas Gleixner Cc: Thomas Bogendoerfer , Geoff Levand , Ilya Dryomov , Dongsheng Yang , Mike Snitzer , "James E.J. Bottomley" , Ira Weiny , dm-devel@redhat.com, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, ceph-devel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 01/18] mm: add a kunmap_local_dirty helper Date: Tue, 15 Jun 2021 15:24:39 +0200 Message-Id: <20210615132456.753241-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210615132456.753241-1-hch@lst.de> References: <20210615132456.753241-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper that calls flush_kernel_dcache_page before unmapping the local mapping. flush_kernel_dcache_page is required for all pages potentially mapped into userspace that were written to using kmap*, so having a helper that does the right thing can be very convenient. Signed-off-by: Christoph Hellwig --- include/linux/highmem-internal.h | 7 +++++++ include/linux/highmem.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index 7902c7d8b55f..bd37706db147 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -224,4 +224,11 @@ do { \ __kunmap_local(__addr); \ } while (0) +#define kunmap_local_dirty(__page, __addr) \ +do { \ + if (!PageSlab(__page)) \ + flush_kernel_dcache_page(__page); \ + kunmap_local(__addr); \ +} while (0) + #endif diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 832b49b50c7b..65f548db4f2d 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -93,6 +93,10 @@ static inline void kmap_flush_unused(void); * On HIGHMEM enabled systems mapping a highmem page has the side effect of * disabling migration in order to keep the virtual address stable across * preemption. No caller of kmap_local_page() can rely on this side effect. + * + * If data is written to the returned kernel mapping, the callers needs to + * unmap the mapping using kunmap_local_dirty(), else kunmap_local() should + * be used. */ static inline void *kmap_local_page(struct page *page); -- 2.30.2