Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2256059rdb; Mon, 20 Nov 2023 06:28:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5tTkHWw9FYSptyi64P49GicQVqOhhsLRO9yXd1BRneHnzZnZaICD4awvXQMq3TJ+RSwcJ X-Received: by 2002:a17:903:447:b0:1cf:6ac3:81ba with SMTP id iw7-20020a170903044700b001cf6ac381bamr264427plb.57.1700490511135; Mon, 20 Nov 2023 06:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700490511; cv=none; d=google.com; s=arc-20160816; b=FJN7m6Eny4Y9XvTpSG2Ypkfg8wxpZlwY7cofz6CWHVzXxCfZHAzraOcCX0f+IJ12TB y3kyo7Fhs5BhK5HF/+RCMxCjpEKzY7WQLjoxg0n4HPoIWunN+qxAA4NS8tv70jPnzSLM qNUphkZdj2Z8Dnsiei+OTPyGno1MQ/VtnTEiygckn8BH2WDg0tIGYCAzuhK3OkeednrF Nxwr2Z4i9dFT+7y/QG+FaK+90CgvC/95oXZf2PQpJ0fK4zumYqElx4LvX1vGD6JW361Y uaJZyLQlj0EP7XG7Ar+jGwXkCsPlT+HrF5qZnMLy/M5gTFjdt4OEPuxoAOqXtyF+iPdx XE2Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UrNUiDQhPRVXPRaqGASTaNUFFHGOEChD1f0OLJ2XEyU=; fh=XH3pxpKr7AUB4GM0Y3GdAQEzWmNMu4SdIEH1hms+9D0=; b=DyOwUrF4WTKqm7QgyjnETu0Y+QEHZrLIAwBoZGdowPvSXD8LdEFsSzPQlgqBmrwfde U2pIAtzpwMfz/197ET8TU83B3izGeE12fBiRA4FzD3tt49S2zr6eZTNGDbakDG0rbYXt THi9wbNLmqzvETSSYY++V+iXTiHdsz8VWdXjhFJpl+yNV7ps3LKpU8yGqEdnYxoimduY laaW8115N9xLKTHVM4EUEHdjovv524PTshImitDFdwpCEhf2WRiURJufoPGgNpX/dJ1G BiFv7kYfM4PSbor/OdocyGmcGRGnjNmbPHzCRoPZfnjW6gUueLRls98YfLasdlN5FwW3 cELA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N5tPuzk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x5-20020a170902b40500b001c9de48fc7asi8256050plr.170.2023.11.20.06.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:28:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N5tPuzk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7E178802885D; Mon, 20 Nov 2023 06:26:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233191AbjKTO0v (ORCPT + 99 others); Mon, 20 Nov 2023 09:26:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233204AbjKTO0u (ORCPT ); Mon, 20 Nov 2023 09:26:50 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE0B11A for ; Mon, 20 Nov 2023 06:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700490406; x=1732026406; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mfeyDKRxFMHuZ0AE0xc+ySqphdof3bC/Ooi7RFDXZW4=; b=N5tPuzk6zfXDPKS2UTP672HktTJXl6Kc8Eb1jeSVkWLBhJUnCN6sCi0C 8Mh7+eFOANAlip4XT4IpfPAkGCGjjvqgxABgZ7VkzJFsJl0o0q7ZgXFpD 2pJsObGj53tGPGAeXWCVgMa00nG0f60Yv6Jq4js7cdNc77lLkFfI47SOd SLJEhoJoME6TbRwLJ8AK8xC+2jLPsCNkfYDUPwnVLa40PPNKgh1rBN2ex D79LH6J4dm1eFNQZEYq184/pl26G/Bwuj5mne2IfxT9NS4YXidMWDN7j8 MMIQW1L3ItKsJgH3jUWN2OhL0RYl6q7Zwn+jEiJklypvhq3qV9I9+ow67 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="370971046" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="370971046" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:26:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="7734299" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.12.244]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:26:44 -0800 From: "Fabio M. De Francesco" To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH] mm/mempool: Replace kmap_atomic() with kmap_local_page() Date: Mon, 20 Nov 2023 15:26:31 +0100 Message-ID: <20231120142640.7077-1-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.5 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 06:26:53 -0800 (PST) kmap_atomic() has been deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page(). kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only in !PREEMPT_RT kernels). The kernel virtual addresses returned by these two API are only valid in the context of the callers (i.e., they cannot be handed to other threads). With kmap_local_page() the mappings are per thread and CPU local like in kmap_atomic(); however, they can handle page-faults and can be called from any context (including interrupts). The tasks that call kmap_local_page() can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and are still valid. The code blocks between the mappings and un-mappings don't rely on the above-mentioned side effects of kmap_atomic(), so that mere replacements of the old API with the new one is all that they require (i.e., there is no need to explicitly call pagefault_disable() and/or preempt_disable()). Cc: Ira Weiny Signed-off-by: Fabio M. De Francesco --- mm/mempool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/mempool.c b/mm/mempool.c index 734bcf5afbb7..b3d2084fd989 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -64,10 +64,10 @@ static void check_element(mempool_t *pool, void *element) } else if (pool->free == mempool_free_pages) { /* Mempools backed by page allocator */ int order = (int)(long)pool->pool_data; - void *addr = kmap_atomic((struct page *)element); + void *addr = kmap_local_page((struct page *)element); __check_element(pool, addr, 1UL << (PAGE_SHIFT + order)); - kunmap_atomic(addr); + kunmap_local(addr); } } @@ -89,10 +89,10 @@ static void poison_element(mempool_t *pool, void *element) } else if (pool->alloc == mempool_alloc_pages) { /* Mempools backed by page allocator */ int order = (int)(long)pool->pool_data; - void *addr = kmap_atomic((struct page *)element); + void *addr = kmap_local_page((struct page *)element); __poison_element(addr, 1UL << (PAGE_SHIFT + order)); - kunmap_atomic(addr); + kunmap_local(addr); } } #else /* CONFIG_DEBUG_SLAB || CONFIG_SLUB_DEBUG_ON */ -- 2.42.0