From patchwork Tue Aug 10 09:11:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12428421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EFBC4338F for ; Tue, 10 Aug 2021 09:11:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E52560F38 for ; Tue, 10 Aug 2021 09:11:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3E52560F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 838896B0071; Tue, 10 Aug 2021 05:11:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E9326B0072; Tue, 10 Aug 2021 05:11:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D78D6B0073; Tue, 10 Aug 2021 05:11:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 5165B6B0071 for ; Tue, 10 Aug 2021 05:11:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E76BD8249980 for ; Tue, 10 Aug 2021 09:11:20 +0000 (UTC) X-FDA: 78458602320.01.3BC08AE Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf21.hostedemail.com (Postfix) with ESMTP id 1FE7DD01E7BC for ; Tue, 10 Aug 2021 09:11:20 +0000 (UTC) Date: Tue, 10 Aug 2021 11:11:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628586677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=NFXJfNn781XNNVDcY5kUpqlmjTmkBhNdsu8RS8eZUYc=; b=1guZWw5kFpOzLe9CgCu9Zwsqj8kUc41QwCHJy7YPmgJkMTTQFUXVf3IasaC4Se5BbCYzGX D3OwY8QES86guIIomKZTddoSUwy7kdfMY51JMbsLABiarGLNj7tE4K7/fsqHP+jeSOBCwf 5hENPIU3kd4mgMRMI1b/ShTipJd1A2i9rGs6TOKmpnXa8aRN8DATvIg1IUpGekx9uNlFkH 6qeh66Ufs4f9H81W0cw7BRtXSsbh6myBDpDphR579FJS/jgaEzjEdsHw+E7wLT+0J6K+kP Kj2ChoE5NPePQCFrwmmylAaPUpn2n1bvCr7rxT4Ty6Kxy3ZLaFtUYSlUH9Jiag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628586677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=NFXJfNn781XNNVDcY5kUpqlmjTmkBhNdsu8RS8eZUYc=; b=SjgUvQGS5tPmr58XE+uym3eTZ1mRLA3KOSAEVet0dgwGUrkcbqHcfwf5AuGgRDJwBd6bhq /x1RrHLi6CdAGzCw== From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Thomas Gleixner , Peter Zijlstra , Andrew Morton Subject: [PATCH] highmem: Don't disable preemption on RT in kmap_atomic() Message-ID: <20210810091116.pocdmaatdcogvdso@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1FE7DD01E7BC Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=1guZWw5k; dkim=pass header.d=linutronix.de header.s=2020e header.b=SjgUvQGS; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf21.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de X-Stat-Signature: qk6gqkzyoc6tm8q9j4rbsszw9s8fi4zz X-HE-Tag: 1628586680-825085 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: kmap_atomic() disables preemption and pagefaults for historical reasons. The conversion to kmap_local(), which only disables migration, cannot be done wholesale because quite some call sites need to be updated to accommodate with the changed semantics. On PREEMPT_RT enabled kernels the kmap_atomic() semantics are problematic due to the implicit disabling of preemption which makes it impossible to acquire 'sleeping' spinlocks within the kmap atomic sections. PREEMPT_RT replaces the preempt_disable() with a migrate_disable() for more than a decade. It could be argued that this is a justification to do this unconditionally, but PREEMPT_RT covers only a limited number of architectures and it disables some functionality which limits the coverage further. Limit the replacement to PREEMPT_RT for now. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Vlastimil Babka --- include/linux/highmem-internal.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index 7902c7d8b55f9..4aa1031d3e4c3 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -90,7 +90,11 @@ static inline void __kunmap_local(void *vaddr) static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot) { - preempt_disable(); + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + migrate_disable(); + else + preempt_disable(); + pagefault_disable(); return __kmap_local_page_prot(page, prot); } @@ -102,7 +106,11 @@ static inline void *kmap_atomic(struct page *page) static inline void *kmap_atomic_pfn(unsigned long pfn) { - preempt_disable(); + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + migrate_disable(); + else + preempt_disable(); + pagefault_disable(); return __kmap_local_pfn_prot(pfn, kmap_prot); } @@ -111,7 +119,10 @@ static inline void __kunmap_atomic(void *addr) { kunmap_local_indexed(addr); pagefault_enable(); - preempt_enable(); + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + migrate_enable(); + else + preempt_enable(); } unsigned int __nr_free_highpages(void); @@ -179,7 +190,10 @@ static inline void __kunmap_local(void *addr) static inline void *kmap_atomic(struct page *page) { - preempt_disable(); + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + migrate_disable(); + else + preempt_disable(); pagefault_disable(); return page_address(page); } @@ -200,7 +214,10 @@ static inline void __kunmap_atomic(void *addr) kunmap_flush_on_unmap(addr); #endif pagefault_enable(); - preempt_enable(); + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + migrate_enable(); + else + preempt_enable(); } static inline unsigned int nr_free_highpages(void) { return 0; }