Message ID | 20231214081039.1919328-1-fabio.maria.de.francesco@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8388979dys; Thu, 14 Dec 2023 00:11:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDxgiFXkinR+KnqEs/Md7fT1bFA5Wgvq0PsTQHbN7D0TS37kijkc4/ox/CqJSNWmgS2mB5 X-Received: by 2002:a05:6e02:194a:b0:35d:59a2:3322 with SMTP id x10-20020a056e02194a00b0035d59a23322mr15900673ilu.38.1702541496851; Thu, 14 Dec 2023 00:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702541496; cv=none; d=google.com; s=arc-20160816; b=OeILed09c9WGjpluiwl8oJJyjlb6JHAIQx95dsuNklRbhf9qFQakrm9mqD7/egXpCV qOEmob4DzDtG/NA0EALtjXzfiS8K9aFvDiQzuuVH1vrN+y9vpHJGj2UA3cE+pyY/Vn7v LZqNboE6rupZ8k0OmbKLhvJ1PFvuyfh7wA2PkriuhDq3/cQ2Hxf4+nm1cx3ZIOxTHSYg al74xpb+9CW3KLg3BYd0gA/4i2FoQBnnYfmH2ZatUc+IbhPGMwW7WTKTMpxaeUI1uxke vuZKlqPyd9CDBuftg9IJ9JdySWvDsWvlNEbM6OV6SFSndqFDxOP/9EPb4iDajqY//uaB pE7w== 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=CNTI+KMQLvhKnjeNbo+J/agOUmrbDWV8WlyDwZcJPxQ=; fh=qDXlVLl7br5m5Sn+oYnwTx/CBlJrf1pIUlN2uc2ZUlU=; b=ZR6x2GlCY2nbciLjoRPyb/P+03ewBeaM/974oQgei8ptxkYj9gK/ht3hHBTGHAOw0k JbpXo1JVe76xla5/6w7xRTwf+HZPP4zFXcpzmMBVASLtOaFXSheDGjh2TDNCGd+AJQ1x 4R+cZUFlOdX/KgzZyXiVXm+VeGYVxYwcEDk26Vqka35xhbOZrH9Rl84pyo0Xg2f+71VJ jJ4AblMLIOmRCFN61lB1f2zH3ZXiwSokdZHcWfxQExdyu42NEQhLxhTGXjja6rzXF8XP dMQsJ3ZU25t2dT1JDgTid2fJhP14wHtu/IijjE8UKgL6Lyt5t/ezmPSVEO5PBj33zRua MyBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ifgF2mMQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t7-20020a632d07000000b005c6606d5b9esi5623774pgt.572.2023.12.14.00.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:11:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ifgF2mMQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id CF39880842E3; Thu, 14 Dec 2023 00:11:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443415AbjLNIK5 (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Thu, 14 Dec 2023 03:10:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234409AbjLNIKv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Dec 2023 03:10:51 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF796B9 for <linux-kernel@vger.kernel.org>; Thu, 14 Dec 2023 00:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702541448; x=1734077448; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=i8XSla6hrQt6zIq4G6Aba+318oa4y1bEQ+Pf+qR2Hcw=; b=ifgF2mMQjm0yl9A2LX2LdpNODtvgS7BZvj7pTxpgP/makPRUeLqwTLkb +PY6uBjZbAhUb2Q441jfPard2lkTLO7HcuzX/u4YZRCBipLadjlqmnZlI QjUCJ07gO1w2aiOMjHzkz4UD0GAF+QaiOSG19dWVUPnzjaIciVNyGv1Ss +jIzFYAimFjidPw5M7DYB8BZojWYVbjgaTDRHpJyv9SsTXph00ygRv+E8 KKj+iDh+ubD7WjTV0Zh/Gt4lhuDJWvCnk05g+3fO88a1RDrwdOJ/IyFC9 TCG94d7uacgaDlsIspaAm66+qPXGzIhl4jP+Ga4PLwZe7mRUP39bo5MYP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="1903236" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="1903236" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 00:10:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="803191192" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="803191192" Received: from mrejmak-mobl.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.24.154]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 00:10:45 -0800 From: "Fabio M. De Francesco" <fabio.maria.de.francesco@linux.intel.com> To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com>, Ira Weiny <ira.weiny@intel.com>, "Fabio M . De Francesco" <fabio.maria.de.francesco@linux.intel.com> Subject: [PATCH] mm/memory: Replace kmap() with kmap_local_page() Date: Thu, 14 Dec 2023 09:10:04 +0100 Message-ID: <20231214081039.1919328-1-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:11:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785244152126593850 X-GMAIL-MSGID: 1785244152126593850 |
Series |
mm/memory: Replace kmap() with kmap_local_page()
|
|
Commit Message
Fabio M. De Francesco
Dec. 14, 2023, 8:10 a.m. UTC
From: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com> kmap() has been deprecated in favor of kmap_local_page(). Therefore, replace kmap() with kmap_local_page() in mm/memory.c. There are two main problems with kmap(): (1) It comes with an overhead as the mapping space is restricted and protected by a global lock for synchronization and (2) it also requires global TLB invalidation when the kmap’s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. With kmap_local_page() the mappings are per thread, CPU local, can take page-faults, and can be called from any context (including interrupts). It is faster than kmap() in kernels with HIGHMEM enabled. The tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. Obviously, thread locality implies that the kernel virtual addresses returned by kmap_local_page() are only valid in the context of the callers (i.e., they cannot be handed to other threads). The use of kmap_local_page() in mm/memory.c does not break the above-mentioned assumption, so it is allowed and preferred. Cc: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@linux.intel.com> --- mm/memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Comments
> From: "Fabio M. De Francesco" <fabio.maria.de.francesco@linux.intel.com> > ... > From: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com> > > ... > > Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@linux.intel.com> We get a complaint from checkpatch (and possibly from Stephen Rothwell) that the From: and Signed-off-by: email addresses differ. I tentatively rewrote your explicit From: to @linux.intel.com, which may have been unwelcome. What can we do here?
On Thursday, 14 December 2023 20:47:47 CET Andrew Morton wrote: > > From: "Fabio M. De Francesco" <fabio.maria.de.francesco@linux.intel.com> > > ... > > From: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com> > > > > ... > > > > Signed-off-by: Fabio M. De Francesco > > <fabio.maria.de.francesco@linux.intel.com> > We get a complaint from checkpatch (and possibly from Stephen Rothwell) > that the From: and Signed-off-by: email addresses differ. > > I tentatively rewrote your explicit From: to @linux.intel.com, which > may have been unwelcome. What can we do here? I have two email addresses and sometimes some confusion arises while configuring. Please discard this patch. I'm going to send another to replace this. Thanks, Fabio
On Friday, 15 December 2023 09:40:33 CET Fabio M. De Francesco wrote: > On Thursday, 14 December 2023 20:47:47 CET Andrew Morton wrote: > > > > [skip] > > > > I tentatively rewrote your explicit From: to @linux.intel.com, which > > may have been unwelcome. What can we do here? > Sorry, in my last message I asked you to discard this patch and sent another one but I hadn't yet understood that you rewrote and accepted it. My English is still not good enough. Thanks for rewriting it. I'm perfectly fine with your decision to rewrite it to @linux.intel.com. Fabio
diff --git a/mm/memory.c b/mm/memory.c index 7d9f6b685032..88377a107fbe 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5852,7 +5852,7 @@ static int __access_remote_vm(struct mm_struct *mm, unsigned long addr, if (bytes > PAGE_SIZE-offset) bytes = PAGE_SIZE-offset; - maddr = kmap(page); + maddr = kmap_local_page(page); if (write) { copy_to_user_page(vma, page, addr, maddr + offset, buf, bytes); @@ -5861,8 +5861,7 @@ static int __access_remote_vm(struct mm_struct *mm, unsigned long addr, copy_from_user_page(vma, page, addr, buf, maddr + offset, bytes); } - kunmap(page); - put_page(page); + unmap_and_put_page(page, maddr); } len -= bytes; buf += bytes;