From patchwork Sun Apr 26 05:54:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11510185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37B1092A for ; Sun, 26 Apr 2020 05:56:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08B77206BF for ; Sun, 26 Apr 2020 05:56:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pD4/SCJ3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08B77206BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ChXP5yi0Bw4YPJeFBkh/WzAioZv0xrq68o11ydlZuUo=; b=pD4/SCJ3mJfbRv 6FUUFtbxs8w81Hbm/BH0fST2vmWJiqN9fhpKKgYojMQWeCWSQjmIAijeNx13LipBEH5dsST4NnceM WfoCh4aOAUL9LFCur4L59jo5OGwPG/C33EQqsyjB65xfTy+pOHeWmiSSypcY2sQnE82CL5XN4QPbx CwzJe3l7vtxTgAKq4C/8vI5WQ5PnCGlQKnOrLgaEMKt0QAEeidBBCi98qhOfHpnFJGJ+6Xxb0T6iH KH4cZqeNlE52NC5Lx16GWJVpcaFixnHQfgrcodkJNBx6gpdA0Cw2uk0dyGi/CtQB9WUqYRp5G+1ts zHRU2Y8C+cxGIlNkkVpg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaGe-0007M2-Fr; Sun, 26 Apr 2020 05:55:52 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFH-0003rg-Vw; Sun, 26 Apr 2020 05:54:30 +0000 IronPort-SDR: iwC66e/4t+95+t8Otc23x80GAIHByGUvB5snt4rgJHHpooiBk/DGwtiqYZf33HU2nMfmSuEQWt 4XbHiDl45DeQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:22 -0700 IronPort-SDR: 5vI0aC2WJoqaA1rHDNfx4RDyW1Iy/jFdcIF6pYkCY1G8ZX2vahQBBRAQFahQ7DWdPPgIrwO58B 3sdyElhYKHjQ== X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="260317587" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:21 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 1/5] arch/kmap: Remove BUG_ON() Date: Sat, 25 Apr 2020 22:54:02 -0700 Message-Id: <20200426055406.134198-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426055406.134198-1-ira.weiny@intel.com> References: <20200426055406.134198-1-ira.weiny@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200425_225428_034808_B917941C X-CRM114-Status: GOOD ( 10.82 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.136 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , "James E.J. Bottomley" , Max Filippov , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Ira Weiny , Dan Williams , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Chris Zankel , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ira Weiny Replace the use of BUG_ON(in_interrupt()) in the kmap() and kunmap() in favor of might_sleep(). Besides the benefits of might_sleep(), this normalizes the implementations such that they can be made generic in subsequent patches. Reviewed-by: Dan Williams Signed-off-by: Ira Weiny --- arch/arc/include/asm/highmem.h | 2 +- arch/arc/mm/highmem.c | 2 +- arch/arm/mm/highmem.c | 2 +- arch/csky/mm/highmem.c | 2 +- arch/microblaze/include/asm/highmem.h | 2 +- arch/mips/mm/highmem.c | 2 +- arch/nds32/mm/highmem.c | 2 +- arch/powerpc/include/asm/highmem.h | 2 +- arch/sparc/include/asm/highmem.h | 4 ++-- arch/x86/mm/highmem_32.c | 3 +-- arch/xtensa/include/asm/highmem.h | 4 ++-- 11 files changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/arc/include/asm/highmem.h b/arch/arc/include/asm/highmem.h index 1af00accb37f..042e92921c4c 100644 --- a/arch/arc/include/asm/highmem.h +++ b/arch/arc/include/asm/highmem.h @@ -45,7 +45,7 @@ static inline void flush_cache_kmaps(void) static inline void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index fc8849e4f72e..39ef7b9a3aa9 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c @@ -51,7 +51,7 @@ static pte_t * fixmap_page_table; void *kmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return page_address(page); diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index a76f8ace9ce6..cc6eb79ef20c 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -42,7 +42,7 @@ EXPORT_SYMBOL(kmap); void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index 813129145f3d..690d678649d1 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c @@ -29,7 +29,7 @@ EXPORT_SYMBOL(kmap); void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h index 332c78e15198..99ced7278b5c 100644 --- a/arch/microblaze/include/asm/highmem.h +++ b/arch/microblaze/include/asm/highmem.h @@ -66,7 +66,7 @@ static inline void *kmap(struct page *page) static inline void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index d08e6d7d533b..edd889f6cede 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c @@ -28,7 +28,7 @@ EXPORT_SYMBOL(kmap); void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index 022779af6148..4c7c28e994ea 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c @@ -24,7 +24,7 @@ EXPORT_SYMBOL(kmap); void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h index a4b65b186ec6..529512f6d65a 100644 --- a/arch/powerpc/include/asm/highmem.h +++ b/arch/powerpc/include/asm/highmem.h @@ -74,7 +74,7 @@ static inline void *kmap(struct page *page) static inline void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h index 18d776925c45..7dd2d4b3f980 100644 --- a/arch/sparc/include/asm/highmem.h +++ b/arch/sparc/include/asm/highmem.h @@ -55,7 +55,7 @@ void kunmap_high(struct page *page); static inline void *kmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return page_address(page); return kmap_high(page); @@ -63,7 +63,7 @@ static inline void *kmap(struct page *page) static inline void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index 0a1898b8552e..8af66382672b 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c @@ -15,8 +15,7 @@ EXPORT_SYMBOL(kmap); void kunmap(struct page *page) { - if (in_interrupt()) - BUG(); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/highmem.h index 04e9340eac4b..413848cc1e56 100644 --- a/arch/xtensa/include/asm/highmem.h +++ b/arch/xtensa/include/asm/highmem.h @@ -73,7 +73,7 @@ static inline void *kmap(struct page *page) */ BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE); - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return page_address(page); return kmap_high(page); @@ -81,7 +81,7 @@ static inline void *kmap(struct page *page) static inline void kunmap(struct page *page) { - BUG_ON(in_interrupt()); + might_sleep(); if (!PageHighMem(page)) return; kunmap_high(page); From patchwork Sun Apr 26 05:54:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11510187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97C4A1667 for ; Sun, 26 Apr 2020 05:56:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D219206BF for ; Sun, 26 Apr 2020 05:56:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RTPyOMMs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D219206BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j0p9j+Ba3ovJrUZdNLD1wmld3/6IU7Z4olk1qiTsuRk=; b=RTPyOMMsi6JS9B SJJS7L7a+Is4heFNfxr4dzXgHg2Mrk0Y9NPnnk9k9oBo4Ax3W6YgZx/Xk1DrVfP1EQa9EGWQSohsj wu7xGt7kxVKz4iA63avZHFlWEN+jNPBWQ2pyVZRFYqtW+eoyM8X/Tm5tISHcRzUNUJF7TTMgGdXBE e9J1vDdFhqpfXZRC8dnTuiA0tuiqnXF/uGx4NEee2yTwVPaR0iRWIkF/X018okXvBL2FnZ/FAnyAu RIcZB2rm2yzYG1VH4Fn6NTsBacS1X5hkMttgmBYV+pzZTp6CzQx0E/gtqic2lxOu3cMvQBQ/c1B1B 5x2b/cILMH5D2wzat+OQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaGt-0007bH-EQ; Sun, 26 Apr 2020 05:56:07 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFR-00043E-9u; Sun, 26 Apr 2020 05:54:41 +0000 IronPort-SDR: ezJW4HDO5kE8xbB4z4AJ5ZvKzO1Ncd1IeWg+EpUyS9RcLb6vOx/fvJK4E3o02mr9XexV0lZDDK R4mlsCqS5ToA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:36 -0700 IronPort-SDR: cx88cSBlRxSL+ntfH3sL2yK1eLs9LSednmue8odGKUh2mrKFYgcR/pzIaZYWqIi2OxqYOInn8s 94VzyyLw2D4A== X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="256859643" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:22 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 2/5] arch/kmap: Remove redundant arch specific kmaps Date: Sat, 25 Apr 2020 22:54:03 -0700 Message-Id: <20200426055406.134198-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426055406.134198-1-ira.weiny@intel.com> References: <20200426055406.134198-1-ira.weiny@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200425_225438_005817_12230A82 X-CRM114-Status: GOOD ( 13.04 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [134.134.136.65 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , "James E.J. Bottomley" , Max Filippov , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Ira Weiny , Dan Williams , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Chris Zankel , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ira Weiny The kmap code for all the architectures is almost 100% identical. Lift the common code to the core. Use ARCH_HAS_KMAP to indicate if an arch needs a special kmap. This also has the benefit of changing kmap() on a number of architectures to be an inline call rather than an actual function. Reviewed-by: Dan Williams Signed-off-by: Ira Weiny --- arch/arc/include/asm/highmem.h | 2 -- arch/arc/mm/highmem.c | 10 ---------- arch/arm/include/asm/highmem.h | 2 -- arch/arm/mm/highmem.c | 9 --------- arch/csky/include/asm/highmem.h | 2 +- arch/csky/mm/highmem.c | 7 +------ arch/microblaze/include/asm/highmem.h | 9 --------- arch/mips/include/asm/highmem.h | 2 +- arch/mips/mm/highmem.c | 7 +------ arch/nds32/include/asm/highmem.h | 2 -- arch/nds32/mm/highmem.c | 12 ------------ arch/powerpc/include/asm/highmem.h | 9 --------- arch/sparc/include/asm/highmem.h | 9 --------- arch/x86/include/asm/highmem.h | 2 -- arch/x86/mm/highmem_32.c | 9 --------- arch/xtensa/include/asm/highmem.h | 6 +----- include/linux/highmem.h | 18 ++++++++++++++++++ 17 files changed, 23 insertions(+), 94 deletions(-) diff --git a/arch/arc/include/asm/highmem.h b/arch/arc/include/asm/highmem.h index 042e92921c4c..96eb67c86961 100644 --- a/arch/arc/include/asm/highmem.h +++ b/arch/arc/include/asm/highmem.h @@ -30,8 +30,6 @@ #include -extern void *kmap(struct page *page); -extern void *kmap_high(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); extern void kunmap_high(struct page *page); diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index 39ef7b9a3aa9..4db13a6b9f3b 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c @@ -49,16 +49,6 @@ extern pte_t * pkmap_page_table; static pte_t * fixmap_page_table; -void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - - return kmap_high(page); -} -EXPORT_SYMBOL(kmap); - void *kmap_atomic(struct page *page) { int idx, cpu_idx; diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h index eb4e4207cd3c..c917522541de 100644 --- a/arch/arm/include/asm/highmem.h +++ b/arch/arm/include/asm/highmem.h @@ -20,7 +20,6 @@ extern pte_t *pkmap_page_table; -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); /* @@ -63,7 +62,6 @@ static inline void *kmap_high_get(struct page *page) * when CONFIG_HIGHMEM is not set. */ #ifdef CONFIG_HIGHMEM -extern void *kmap(struct page *page); extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index cc6eb79ef20c..e8ba37c36590 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -31,15 +31,6 @@ static inline pte_t get_fixmap_pte(unsigned long vaddr) return *ptep; } -void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); -} -EXPORT_SYMBOL(kmap); - void kunmap(struct page *page) { might_sleep(); diff --git a/arch/csky/include/asm/highmem.h b/arch/csky/include/asm/highmem.h index a345a2f2c22e..4caeff143748 100644 --- a/arch/csky/include/asm/highmem.h +++ b/arch/csky/include/asm/highmem.h @@ -30,9 +30,9 @@ extern pte_t *pkmap_page_table; #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); +#define ARCH_HAS_KMAP extern void *kmap(struct page *page); extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index 690d678649d1..5fb0bd855444 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c @@ -15,14 +15,9 @@ unsigned long highstart_pfn, highend_pfn; void *kmap(struct page *page) { - void *addr; + void *addr = kmap_generic(page); - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - addr = kmap_high(page); flush_tlb_one((unsigned long)addr); - return addr; } EXPORT_SYMBOL(kmap); diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h index 99ced7278b5c..8c5bfd228bd8 100644 --- a/arch/microblaze/include/asm/highmem.h +++ b/arch/microblaze/include/asm/highmem.h @@ -51,19 +51,10 @@ extern pte_t *pkmap_page_table; #define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); extern void *kmap_atomic_prot(struct page *page, pgprot_t prot); extern void __kunmap_atomic(void *kvaddr); -static inline void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); -} - static inline void kunmap(struct page *page) { might_sleep(); diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h index 9d84aafc33d0..c30bbb88fcfe 100644 --- a/arch/mips/include/asm/highmem.h +++ b/arch/mips/include/asm/highmem.h @@ -46,9 +46,9 @@ extern pte_t *pkmap_page_table; #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) -extern void * kmap_high(struct page *page); extern void kunmap_high(struct page *page); +#define ARCH_HAS_KMAP extern void *kmap(struct page *page); extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index edd889f6cede..3867dbe9ef32 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c @@ -14,14 +14,9 @@ unsigned long highstart_pfn, highend_pfn; void *kmap(struct page *page) { - void *addr; + void *addr = kmap_generic(page); - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - addr = kmap_high(page); flush_tlb_one((unsigned long)addr); - return addr; } EXPORT_SYMBOL(kmap); diff --git a/arch/nds32/include/asm/highmem.h b/arch/nds32/include/asm/highmem.h index b3a82c97ded3..b13654a79069 100644 --- a/arch/nds32/include/asm/highmem.h +++ b/arch/nds32/include/asm/highmem.h @@ -44,7 +44,6 @@ extern unsigned long highstart_pfn, highend_pfn; extern pte_t *pkmap_page_table; -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); extern void kmap_init(void); @@ -54,7 +53,6 @@ extern void kmap_init(void); * when CONFIG_HIGHMEM is not set. */ #ifdef CONFIG_HIGHMEM -extern void *kmap(struct page *page); extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index 4c7c28e994ea..d0cde53b84ae 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c @@ -10,18 +10,6 @@ #include #include -void *kmap(struct page *page) -{ - unsigned long vaddr; - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - vaddr = (unsigned long)kmap_high(page); - return (void *)vaddr; -} - -EXPORT_SYMBOL(kmap); - void kunmap(struct page *page) { might_sleep(); diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h index 529512f6d65a..f14e4feef6d5 100644 --- a/arch/powerpc/include/asm/highmem.h +++ b/arch/powerpc/include/asm/highmem.h @@ -59,19 +59,10 @@ extern pte_t *pkmap_page_table; #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); extern void *kmap_atomic_prot(struct page *page, pgprot_t prot); extern void __kunmap_atomic(void *kvaddr); -static inline void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); -} - static inline void kunmap(struct page *page) { might_sleep(); diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h index 7dd2d4b3f980..2ff1192047f7 100644 --- a/arch/sparc/include/asm/highmem.h +++ b/arch/sparc/include/asm/highmem.h @@ -50,17 +50,8 @@ void kmap_init(void) __init; #define PKMAP_END (PKMAP_ADDR(LAST_PKMAP)) -void *kmap_high(struct page *page); void kunmap_high(struct page *page); -static inline void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); -} - static inline void kunmap(struct page *page) { might_sleep(); diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h index a8059930056d..c916a28a9738 100644 --- a/arch/x86/include/asm/highmem.h +++ b/arch/x86/include/asm/highmem.h @@ -58,10 +58,8 @@ extern unsigned long highstart_pfn, highend_pfn; #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) -extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); -void *kmap(struct page *page); void kunmap(struct page *page); void *kmap_atomic_prot(struct page *page, pgprot_t prot); diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index 8af66382672b..12591a81b85c 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c @@ -4,15 +4,6 @@ #include /* for totalram_pages */ #include -void *kmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); -} -EXPORT_SYMBOL(kmap); - void kunmap(struct page *page) { might_sleep(); diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/highmem.h index 413848cc1e56..fac4f48bde6c 100644 --- a/arch/xtensa/include/asm/highmem.h +++ b/arch/xtensa/include/asm/highmem.h @@ -63,7 +63,6 @@ static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color) extern pte_t *pkmap_page_table; -void *kmap_high(struct page *page); void kunmap_high(struct page *page); static inline void *kmap(struct page *page) @@ -73,10 +72,7 @@ static inline void *kmap(struct page *page) */ BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE); - might_sleep(); - if (!PageHighMem(page)) - return page_address(page); - return kmap_high(page); + return kmap_generic(page); } static inline void kunmap(struct page *page) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index ea5cdbd8c2c3..2f7f710b7e7d 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -32,8 +32,26 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size) #include #ifdef CONFIG_HIGHMEM +extern void *kmap_high(struct page *page); + +/* kmap_generic: architecture independent portion of kmap calls */ +static inline void *kmap_generic(struct page *page) +{ + might_sleep(); + if (!PageHighMem(page)) + return page_address(page); + return kmap_high(page); +} + #include +#ifndef ARCH_HAS_KMAP +static inline void *kmap(struct page *page) +{ + return kmap_generic(page); +} +#endif + /* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages(void); extern atomic_long_t _totalhigh_pages; From patchwork Sun Apr 26 05:54:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11510183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A10CD92A for ; Sun, 26 Apr 2020 05:55:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B86A206BF for ; Sun, 26 Apr 2020 05:55:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Xbtoqcxp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B86A206BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Rg4KloY/ErEs2IdRWVus8SC6ueyP5fh8uQNc7ToSFlc=; b=Xbtoqcxp5xkMWb fJ8g07E2sCmHaoONj5Dc3cocLqWM3S02+xgHSeaRczZO6s5Ap2emNzjiesBLx43bRVFmtwkyGEfH0 JqRATOrWlh2wzd8G4n0NP+N+zaifcyU1OLvfs3RL/A7OrXwiYJy0s+PMieUE6G2SSfowbyB1qCQ6P Hkm9ywso5UDydsJvWxRJjzNYu0Gjyg05RIcF7EEDuh+oxPRG/fYOZqRcm0a7XW/Bo82FWDqN1Lxkb 2N7BTZulrCCnn8N4glogULtnwcL+oaZyBR7MDRShYkamyB0WQpRJAjPzY4/6uRjwGbh18K60ALyzG qPlx9523xnkmzyAhvgfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaGL-00073t-Pl; Sun, 26 Apr 2020 05:55:33 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFH-0003rm-SU; Sun, 26 Apr 2020 05:54:30 +0000 IronPort-SDR: /jsY1tRI/gO99rT/LTNAr8v366k81EUWWc601Cjx2M1h6MdcLQFUvTRCTknO1wEeBQZRzEOVw3 XY1ARnnTBEZQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:23 -0700 IronPort-SDR: OkT3JFTLADkNjn3UowLHjtWAG/8+lfmHPe7Y3tdnmzHkWlptAPlMqa7rHtAf79YOBGXzoBP6cc KBC96wVpnPDQ== X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="458418423" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:22 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 3/5] arch/kunmap: Remove duplicate kunmap implementations Date: Sat, 25 Apr 2020 22:54:04 -0700 Message-Id: <20200426055406.134198-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426055406.134198-1-ira.weiny@intel.com> References: <20200426055406.134198-1-ira.weiny@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200425_225427_927971_5FB3ED1F X-CRM114-Status: GOOD ( 12.80 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , "James E.J. Bottomley" , Max Filippov , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Ira Weiny , Dan Williams , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Chris Zankel , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ira Weiny All architectures do exactly the same thing for kunmap(); remove all the duplicate definitions and lift the call to the core. Reviewed-by: Dan Williams Signed-off-by: Ira Weiny --- arch/arc/include/asm/highmem.h | 9 --------- arch/arm/include/asm/highmem.h | 1 - arch/arm/mm/highmem.c | 9 --------- arch/csky/include/asm/highmem.h | 1 - arch/csky/mm/highmem.c | 9 --------- arch/microblaze/include/asm/highmem.h | 8 -------- arch/mips/include/asm/highmem.h | 1 - arch/mips/mm/highmem.c | 9 --------- arch/nds32/include/asm/highmem.h | 1 - arch/nds32/mm/highmem.c | 10 ---------- arch/powerpc/include/asm/highmem.h | 8 -------- arch/sparc/include/asm/highmem.h | 8 -------- arch/x86/include/asm/highmem.h | 2 -- arch/x86/mm/highmem_32.c | 9 --------- arch/xtensa/include/asm/highmem.h | 8 -------- include/linux/highmem.h | 8 ++++++++ 16 files changed, 8 insertions(+), 93 deletions(-) diff --git a/arch/arc/include/asm/highmem.h b/arch/arc/include/asm/highmem.h index 96eb67c86961..c03a911c9f21 100644 --- a/arch/arc/include/asm/highmem.h +++ b/arch/arc/include/asm/highmem.h @@ -41,15 +41,6 @@ static inline void flush_cache_kmaps(void) flush_cache_all(); } -static inline void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - - #endif #endif diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h index c917522541de..829e3b969819 100644 --- a/arch/arm/include/asm/highmem.h +++ b/arch/arm/include/asm/highmem.h @@ -62,7 +62,6 @@ static inline void *kmap_high_get(struct page *page) * when CONFIG_HIGHMEM is not set. */ #ifdef CONFIG_HIGHMEM -extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); extern void *kmap_atomic_pfn(unsigned long pfn); diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index e8ba37c36590..c700b32350ee 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -31,15 +31,6 @@ static inline pte_t get_fixmap_pte(unsigned long vaddr) return *ptep; } -void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} -EXPORT_SYMBOL(kunmap); - void *kmap_atomic(struct page *page) { unsigned int idx; diff --git a/arch/csky/include/asm/highmem.h b/arch/csky/include/asm/highmem.h index 4caeff143748..a0e7c43731a0 100644 --- a/arch/csky/include/asm/highmem.h +++ b/arch/csky/include/asm/highmem.h @@ -34,7 +34,6 @@ extern void kunmap_high(struct page *page); #define ARCH_HAS_KMAP extern void *kmap(struct page *page); -extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); extern void *kmap_atomic_pfn(unsigned long pfn); diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index 5fb0bd855444..69b1931986ae 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c @@ -22,15 +22,6 @@ void *kmap(struct page *page) } EXPORT_SYMBOL(kmap); -void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} -EXPORT_SYMBOL(kunmap); - void *kmap_atomic(struct page *page) { unsigned long vaddr; diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h index 8c5bfd228bd8..1cbd52a0e39b 100644 --- a/arch/microblaze/include/asm/highmem.h +++ b/arch/microblaze/include/asm/highmem.h @@ -55,14 +55,6 @@ extern void kunmap_high(struct page *page); extern void *kmap_atomic_prot(struct page *page, pgprot_t prot); extern void __kunmap_atomic(void *kvaddr); -static inline void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - static inline void *kmap_atomic(struct page *page) { return kmap_atomic_prot(page, kmap_prot); diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h index c30bbb88fcfe..af9a66300628 100644 --- a/arch/mips/include/asm/highmem.h +++ b/arch/mips/include/asm/highmem.h @@ -50,7 +50,6 @@ extern void kunmap_high(struct page *page); #define ARCH_HAS_KMAP extern void *kmap(struct page *page); -extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); extern void *kmap_atomic_pfn(unsigned long pfn); diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index 3867dbe9ef32..c3c9fe962f0f 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c @@ -21,15 +21,6 @@ void *kmap(struct page *page) } EXPORT_SYMBOL(kmap); -void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} -EXPORT_SYMBOL(kunmap); - /* * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because * no global lock is needed and because the kmap code must perform a global TLB diff --git a/arch/nds32/include/asm/highmem.h b/arch/nds32/include/asm/highmem.h index b13654a79069..e455e2624247 100644 --- a/arch/nds32/include/asm/highmem.h +++ b/arch/nds32/include/asm/highmem.h @@ -53,7 +53,6 @@ extern void kmap_init(void); * when CONFIG_HIGHMEM is not set. */ #ifdef CONFIG_HIGHMEM -extern void kunmap(struct page *page); extern void *kmap_atomic(struct page *page); extern void __kunmap_atomic(void *kvaddr); extern void *kmap_atomic_pfn(unsigned long pfn); diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index d0cde53b84ae..f9348bec0ecb 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c @@ -10,16 +10,6 @@ #include #include -void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - -EXPORT_SYMBOL(kunmap); - void *kmap_atomic(struct page *page) { unsigned int idx; diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h index f14e4feef6d5..08e02a4f3a8f 100644 --- a/arch/powerpc/include/asm/highmem.h +++ b/arch/powerpc/include/asm/highmem.h @@ -63,14 +63,6 @@ extern void kunmap_high(struct page *page); extern void *kmap_atomic_prot(struct page *page, pgprot_t prot); extern void __kunmap_atomic(void *kvaddr); -static inline void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - static inline void *kmap_atomic(struct page *page) { return kmap_atomic_prot(page, kmap_prot); diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h index 2ff1192047f7..b3ee234b2a8f 100644 --- a/arch/sparc/include/asm/highmem.h +++ b/arch/sparc/include/asm/highmem.h @@ -52,14 +52,6 @@ void kmap_init(void) __init; void kunmap_high(struct page *page); -static inline void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - void *kmap_atomic(struct page *page); void __kunmap_atomic(void *kvaddr); diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h index c916a28a9738..102cdcde74cb 100644 --- a/arch/x86/include/asm/highmem.h +++ b/arch/x86/include/asm/highmem.h @@ -60,8 +60,6 @@ extern unsigned long highstart_pfn, highend_pfn; extern void kunmap_high(struct page *page); -void kunmap(struct page *page); - void *kmap_atomic_prot(struct page *page, pgprot_t prot); void *kmap_atomic(struct page *page); void __kunmap_atomic(void *kvaddr); diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index 12591a81b85c..c4ebfd0ae401 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c @@ -4,15 +4,6 @@ #include /* for totalram_pages */ #include -void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} -EXPORT_SYMBOL(kunmap); - /* * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because * no global lock is needed and because the kmap code must perform a global TLB diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/highmem.h index fac4f48bde6c..ae9e0ffbdb80 100644 --- a/arch/xtensa/include/asm/highmem.h +++ b/arch/xtensa/include/asm/highmem.h @@ -75,14 +75,6 @@ static inline void *kmap(struct page *page) return kmap_generic(page); } -static inline void kunmap(struct page *page) -{ - might_sleep(); - if (!PageHighMem(page)) - return; - kunmap_high(page); -} - static inline void flush_cache_kmaps(void) { flush_cache_all(); diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 2f7f710b7e7d..1a3b7690c78c 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -52,6 +52,14 @@ static inline void *kmap(struct page *page) } #endif +static inline void kunmap(struct page *page) +{ + might_sleep(); + if (!PageHighMem(page)) + return; + kunmap_high(page); +} + /* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages(void); extern atomic_long_t _totalhigh_pages; From patchwork Sun Apr 26 05:54:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11510167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 546851667 for ; Sun, 26 Apr 2020 05:54:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 311CB2098B for ; Sun, 26 Apr 2020 05:54:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KimH5wMi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 311CB2098B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ucLYIJLHwtwe9o4kvdKyfQy+B9a6gl6t1xOkFmy56bU=; b=KimH5wMic021+A YlfOf+s130BuJMAAnHF/bSF7gZfABjhRWq+jd8YMSfPaSG1s9OcSdk4D6lkwtbXeDmDzZjK31jBXc fq1xj8EBgwLUn9e+x1XU31BN0Ctat67ejfR2UJB+APWpk3aTg2TvBNOILReMQGOTXqNliJLwoDRjx Tjz80VTRpjX1bDZIhNV7BbYMwLoAki5SAm6s+qZbmrygXmJxNNYmacFO87Qlf55MENfN3No/yQkyt WNLZPl9iPriIlknAgJgFqcIfpKPaGSRTCpoPOSq4NWg+TQ0oQ7LmKT99ObYJeJ2LMiGX2tjwpo8LF BjHSA1WV5fLBuA9mRsHA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFJ-0003uQ-FO; Sun, 26 Apr 2020 05:54:29 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFG-0003rq-Td; Sun, 26 Apr 2020 05:54:28 +0000 IronPort-SDR: qJDn8OSbFAeHsfHQXVY84fAX0Vr3e9DXzKgOuN3PRiVwBtySNwXL/uT9C8A/lpYjq11e2Onnn4 KkmO8o5PMP6A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:23 -0700 IronPort-SDR: JbrFxZQOg4mMIuwtoATzRdij1dRliQGnUgWcjgmHA5TRHF3mzGglJEjgI5nDw5LX1Vgmb6bj/B U1DQQme6oOjQ== X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="302014809" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:23 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 4/5] arch/kmap_atomic: Consolidate duplicate code Date: Sat, 25 Apr 2020 22:54:05 -0700 Message-Id: <20200426055406.134198-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426055406.134198-1-ira.weiny@intel.com> References: <20200426055406.134198-1-ira.weiny@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200425_225426_971091_97459AB6 X-CRM114-Status: GOOD ( 10.52 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.151 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , "James E.J. Bottomley" , Max Filippov , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Ira Weiny , Dan Williams , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Chris Zankel , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ira Weiny Every arch has the same check for a not HIGHMEM page. Define kmap_atomic_fast() to quickly return already mapped pages and reduce the code duplication by lifting this check to the core. Reviewed-by: Dan Williams Signed-off-by: Ira Weiny --- arch/arc/mm/highmem.c | 7 +++---- arch/arm/mm/highmem.c | 8 +++----- arch/csky/mm/highmem.c | 7 +++---- arch/microblaze/mm/highmem.c | 8 +++----- arch/mips/mm/highmem.c | 7 +++---- arch/nds32/mm/highmem.c | 7 +++---- arch/powerpc/mm/highmem.c | 7 +++---- arch/sparc/mm/highmem.c | 7 +++---- arch/x86/mm/highmem_32.c | 8 +++----- arch/xtensa/mm/highmem.c | 7 +++---- include/linux/highmem.h | 9 +++++++++ 11 files changed, 39 insertions(+), 43 deletions(-) diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index 4db13a6b9f3b..1cae4b911a33 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c @@ -53,11 +53,10 @@ void *kmap_atomic(struct page *page) { int idx, cpu_idx; unsigned long vaddr; + void *addr = kmap_atomic_fast(page); - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; cpu_idx = kmap_atomic_idx_push(); idx = cpu_idx + KM_TYPE_NR * smp_processor_id(); diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index c700b32350ee..4a629f616a6a 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -35,13 +35,11 @@ void *kmap_atomic(struct page *page) { unsigned int idx; unsigned long vaddr; - void *kmap; + void *kmap = kmap_atomic_fast(page); int type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (kmap) + return kmap; #ifdef CONFIG_DEBUG_HIGHMEM /* diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index 69b1931986ae..1191f57f53ae 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c @@ -25,12 +25,11 @@ EXPORT_SYMBOL(kmap); void *kmap_atomic(struct page *page) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); int idx, type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/microblaze/mm/highmem.c b/arch/microblaze/mm/highmem.c index d7569f77fa15..99fdf826edc2 100644 --- a/arch/microblaze/mm/highmem.c +++ b/arch/microblaze/mm/highmem.c @@ -36,13 +36,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); int idx, type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); - + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index c3c9fe962f0f..ba03ca75d4a1 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c @@ -33,12 +33,11 @@ EXPORT_SYMBOL(kmap); void *kmap_atomic(struct page *page) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); int idx, type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index f9348bec0ecb..4aabde586489 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c @@ -14,13 +14,12 @@ void *kmap_atomic(struct page *page) { unsigned int idx; unsigned long vaddr, pte; + void *addr = kmap_atomic_fast(page); int type; pte_t *ptep; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c index 320c1672b2ae..cdf5b716801a 100644 --- a/arch/powerpc/mm/highmem.c +++ b/arch/powerpc/mm/highmem.c @@ -33,12 +33,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); int idx, type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c index d4a80adea7e5..178641805567 100644 --- a/arch/sparc/mm/highmem.c +++ b/arch/sparc/mm/highmem.c @@ -56,12 +56,11 @@ void __init kmap_init(void) void *kmap_atomic(struct page *page) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); long idx, type; - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index c4ebfd0ae401..34770499b0ff 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c @@ -15,13 +15,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot) { unsigned long vaddr; + void *addr = kmap_atomic_fast(page); int idx, type; - preempt_disable(); - pagefault_disable(); - - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR*smp_processor_id(); diff --git a/arch/xtensa/mm/highmem.c b/arch/xtensa/mm/highmem.c index 184ceadccc1a..38c14e0b578c 100644 --- a/arch/xtensa/mm/highmem.c +++ b/arch/xtensa/mm/highmem.c @@ -41,11 +41,10 @@ void *kmap_atomic(struct page *page) { enum fixed_addresses idx; unsigned long vaddr; + void *addr = kmap_atomic_fast(page); - preempt_disable(); - pagefault_disable(); - if (!PageHighMem(page)) - return page_address(page); + if (addr) + return addr; idx = kmap_idx(kmap_atomic_idx_push(), DCACHE_ALIAS(page_to_phys(page))); diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 1a3b7690c78c..eee53e151900 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -60,6 +60,15 @@ static inline void kunmap(struct page *page) kunmap_high(page); } +static inline void *kmap_atomic_fast(struct page *page) +{ + preempt_disable(); + pagefault_disable(); + if (!PageHighMem(page)) + return page_address(page); + return NULL; +} + /* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages(void); extern atomic_long_t _totalhigh_pages; From patchwork Sun Apr 26 05:54:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11510179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8687292A for ; Sun, 26 Apr 2020 05:54:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 179692098B for ; Sun, 26 Apr 2020 05:54:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j//ZuRYB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 179692098B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0nAJDKHQslmZI3gLdQAajyKnBv5O79cVqL+bvNUvznE=; b=j//ZuRYBhAn4IW 6ZxIpvke5LPDuXR3gPfpSfjZOtfcZ9xJQx/Gxs2xEQLW2INiJ4ZcjMI6naG8Aad6NzzTZ58UcAS/U GDD0/XbnPBBsGYMzfxeVTOPnGyvqLbP1m6yilUxPhQkiWHBM8T+Vxqv2qIZBIWS07yPYCt/IFm2RO OgFe4hz2QCKsd26jIwRT6Ct2l3S5PI2a7bL58/ER/SeyG2y9P34DNMxZjoKKChIbiOL1lcm2j59yV GwLTmF1GBaRXswiGMAZw+TANKgs5ep4BenlfUNDdEvXtuNh+1Fmg8ZLcJkgMJXY+Txlz0O4glbjFc ZghWsNadZ8xJxbY278BQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFW-00043F-JA; Sun, 26 Apr 2020 05:54:42 +0000 Received: from mga06.intel.com ([134.134.136.31]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSaFH-0003rz-Am; Sun, 26 Apr 2020 05:54:28 +0000 IronPort-SDR: ZgoeIZ50wETB7EmEch6hZsJCCTbOrOiWK4qgSudL67A/dzLkFQpYCz51aIoCZUdubWTam/yb7y dstQ28Sf1xqQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:24 -0700 IronPort-SDR: ULIPpftXlRuZVncLUHSwuauSzU7AMt8SQ3FSLW4e25oH6OANV+RbXbJFufO4yzakpq0D15kNUU 6n3sFI9wk+2w== X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="245732999" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 22:54:23 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 5/5] arch/kunmap_atomic: Consolidate duplicate code Date: Sat, 25 Apr 2020 22:54:06 -0700 Message-Id: <20200426055406.134198-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200426055406.134198-1-ira.weiny@intel.com> References: <20200426055406.134198-1-ira.weiny@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200425_225427_430708_58BD6C03 X-CRM114-Status: GOOD ( 12.05 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [134.134.136.31 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , "James E.J. Bottomley" , Max Filippov , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Ira Weiny , Dan Williams , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Chris Zankel , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ira Weiny Every single architecture (including !CONFIG_HIGHMEM) calls... pagefault_enable(); preempt_enable(); ... before returning from __kunmap_atomic(). Lift this code into the kunmap_atomic() macro. Reviewed-by: Dan Williams Signed-off-by: Ira Weiny --- arch/arc/mm/highmem.c | 3 --- arch/arm/mm/highmem.c | 2 -- arch/csky/mm/highmem.c | 5 +---- arch/microblaze/mm/highmem.c | 2 -- arch/mips/mm/highmem.c | 2 -- arch/nds32/mm/highmem.c | 2 -- arch/parisc/include/asm/cacheflush.h | 2 -- arch/powerpc/mm/highmem.c | 2 -- arch/sparc/mm/highmem.c | 2 -- arch/x86/mm/highmem_32.c | 3 --- arch/xtensa/mm/highmem.c | 3 --- include/linux/highmem.h | 6 ++++-- 12 files changed, 5 insertions(+), 29 deletions(-) diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index 1cae4b911a33..0725fc56b016 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c @@ -91,9 +91,6 @@ void __kunmap_atomic(void *kv) kmap_atomic_idx_pop(); } - - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index 4a629f616a6a..4983bf18ec32 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -98,8 +98,6 @@ void __kunmap_atomic(void *kvaddr) /* this address was obtained through kmap_high_get() */ kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)])); } - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index 1191f57f53ae..106fa6773084 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c @@ -50,7 +50,7 @@ void __kunmap_atomic(void *kvaddr) int idx; if (vaddr < FIXADDR_START) - goto out; + return; #ifdef CONFIG_DEBUG_HIGHMEM idx = KM_TYPE_NR*smp_processor_id() + kmap_atomic_idx(); @@ -63,9 +63,6 @@ void __kunmap_atomic(void *kvaddr) (void) idx; /* to kill a warning */ #endif kmap_atomic_idx_pop(); -out: - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/microblaze/mm/highmem.c b/arch/microblaze/mm/highmem.c index 99fdf826edc2..d382c6821747 100644 --- a/arch/microblaze/mm/highmem.c +++ b/arch/microblaze/mm/highmem.c @@ -81,7 +81,5 @@ void __kunmap_atomic(void *kvaddr) local_flush_tlb_page(NULL, vaddr); kmap_atomic_idx_pop(); - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index ba03ca75d4a1..5a3fc7e84e66 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c @@ -79,8 +79,6 @@ void __kunmap_atomic(void *kvaddr) } #endif kmap_atomic_idx_pop(); - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index 4aabde586489..b8862aafa189 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c @@ -49,8 +49,6 @@ void __kunmap_atomic(void *kvaddr) ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr); set_pte(ptep, 0); } - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h index 0c83644bfa5c..c8458491b9af 100644 --- a/arch/parisc/include/asm/cacheflush.h +++ b/arch/parisc/include/asm/cacheflush.h @@ -125,8 +125,6 @@ static inline void *kmap_atomic(struct page *page) static inline void __kunmap_atomic(void *addr) { flush_kernel_dcache_page_addr(addr); - pagefault_enable(); - preempt_enable(); } #define kmap_atomic_prot(page, prot) kmap_atomic(page) diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c index cdf5b716801a..7dfccf519621 100644 --- a/arch/powerpc/mm/highmem.c +++ b/arch/powerpc/mm/highmem.c @@ -76,7 +76,5 @@ void __kunmap_atomic(void *kvaddr) } kmap_atomic_idx_pop(); - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c index 178641805567..7a99a1097f67 100644 --- a/arch/sparc/mm/highmem.c +++ b/arch/sparc/mm/highmem.c @@ -130,7 +130,5 @@ void __kunmap_atomic(void *kvaddr) #endif kmap_atomic_idx_pop(); - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index 34770499b0ff..b20e81b2b833 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c @@ -78,9 +78,6 @@ void __kunmap_atomic(void *kvaddr) BUG_ON(vaddr >= (unsigned long)high_memory); } #endif - - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/arch/xtensa/mm/highmem.c b/arch/xtensa/mm/highmem.c index 38c14e0b578c..9a49263e4cd6 100644 --- a/arch/xtensa/mm/highmem.c +++ b/arch/xtensa/mm/highmem.c @@ -77,9 +77,6 @@ void __kunmap_atomic(void *kvaddr) kmap_atomic_idx_pop(); } - - pagefault_enable(); - preempt_enable(); } EXPORT_SYMBOL(__kunmap_atomic); diff --git a/include/linux/highmem.h b/include/linux/highmem.h index eee53e151900..94145d4200ab 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -133,8 +133,8 @@ static inline void *kmap_atomic(struct page *page) static inline void __kunmap_atomic(void *addr) { - pagefault_enable(); - preempt_enable(); + /* Nothing to do in the CONFIG_HIGHMEM=n case as kunmap_atomic() + * handles re-enabling faults + preemption */ } #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn)) @@ -185,6 +185,8 @@ static inline void kmap_atomic_idx_pop(void) do { \ BUILD_BUG_ON(__same_type((addr), struct page *)); \ __kunmap_atomic(addr); \ + pagefault_enable(); \ + preempt_enable(); \ } while (0)