Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp705549pxu; Thu, 3 Dec 2020 10:30:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeOWf57sDxZJULb4tyJDgQaMY6oD918kZXLSc131iQJORDbKtu6p2GC4UkB6wBeGONyOte X-Received: by 2002:a17:906:26cc:: with SMTP id u12mr3828366ejc.295.1607020255655; Thu, 03 Dec 2020 10:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607020255; cv=none; d=google.com; s=arc-20160816; b=FW1NLWtvqN/4Faq+6Vnzl6S8ZTB0PvxZUxxqWNRQnOJQKVwGQAmct+zNXVFNDw8bW7 w1DlOuKGbUSpgymU2Vs/NRprUdsVTHxnb6Kd3iORRc3Xt51pS6vMnrCQvHUBxVGnOPVP 6eG/ddwg/XlSCDkQyOiAuQWAv9QXwpktQ9iW/BPEUx6Y6PB3h3wtU4nS7AlCpq4ljlOg 9EYhjR0U4pQvQa9RngimybcZQtt8sPPHysykJ4qjb+FgvCgtP5vGR47iQ2zGpoDbqBwr TAtUgdrV5HZcksETRFpmwhXpqIqCtZy+X/CVNab+IxTG8kv3/1XZN+lOE7CzgBeMOfEj VIHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=Sh4sdbHAiHnTeCKJgSjyz3JbPqjMwBh3mYdSGvCQDwQ=; b=dJ4Zf9oRs2p4C8e10nKWqdQd16SGYHtWhJyszmFFtQvkf2oLlDJv15p2aODEdkjcrk 7BmbaMRcQWlMVfo7gBvaKiiVp5geUkE0Av3OnmzC20fLPWcJ4e5XwtuXSAWKBKmI+oj4 xqd6BcsIb7CekYwDo2mLykh1ZnBqHXF0pGsWBHiwOAbAclKAmldBVF79ufqvbgGrCrei rXgGv0ajv/jqFixKVcLcMlV4j7jQUVE1xUtL3L4P8zHcK9yz37jPek6QHO7AclkY0BH1 h+/Qwp3/odZxQBTwQ4AfRfxAAn45sm6SdbjEHyopt7TobgiJv3gnDEVjl5EXmq0uApg9 rWEA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e4si1542578ejq.356.2020.12.03.10.30.32; Thu, 03 Dec 2020 10:30:55 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502116AbgLCSZt (ORCPT + 99 others); Thu, 3 Dec 2020 13:25:49 -0500 Received: from mga06.intel.com ([134.134.136.31]:48382 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502109AbgLCSZs (ORCPT ); Thu, 3 Dec 2020 13:25:48 -0500 IronPort-SDR: Wz80Pepfadsapr9z5+7kR8TorwCrcXys6lSG3FzxCWjm5kXDPWu6h89TYySb7rPgLNurQt+R1I xd9Ci4o53h6g== X-IronPort-AV: E=McAfee;i="6000,8403,9824"; a="234854261" X-IronPort-AV: E=Sophos;i="5.78,390,1599548400"; d="scan'208";a="234854261" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2020 10:25:06 -0800 IronPort-SDR: 1yZ6ymN8T1Ru5eWK//GwNd0draYxhFs3e3pHjha5XL21vzCJ0JYjmIZPD/XgmhI3I+/Mc4Ybv7 bQ4yqVHtbb5Q== X-IronPort-AV: E=Sophos;i="5.78,390,1599548400"; d="scan'208";a="482069934" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2020 10:25:05 -0800 Date: Thu, 3 Dec 2020 10:25:05 -0800 From: Ira Weiny To: Joonas Lahtinen Cc: Matthew Wilcox , Andrew Morton , Dave Hansen , Christoph Hellwig , Dan Williams , Al Viro , Eric Biggers , Thomas Gleixner , Luis Chamberlain , Patrik Jakobsson , Jani Nikula , Rodrigo Vivi , David Howells , Chris Mason , Josef Bacik , David Sterba , Steve French , Jaegeuk Kim , Chao Yu , Nicolas Pitre , "Martin K. Petersen" , Brian King , Greg Kroah-Hartman , Alexei Starovoitov , Daniel Borkmann , =?iso-8859-1?B?Suly9G1l?= Glisse , Kirti Wankhede , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 01/17] mm/highmem: Lift memcpy_[to|from]_page and memset_page to core Message-ID: <20201203182505.GD1563847@iweiny-DESK2.sc.intel.com> References: <20201124060755.1405602-1-ira.weiny@intel.com> <20201124060755.1405602-2-ira.weiny@intel.com> <160648238432.10416.12405581766428273347@jlahtine-mobl.ger.corp.intel.com> <20201127132006.GY4327@casper.infradead.org> <160672815223.3453.2374529656870007787@jlahtine-mobl.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <160672815223.3453.2374529656870007787@jlahtine-mobl.ger.corp.intel.com> User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 30, 2020 at 11:22:32AM +0200, Joonas Lahtinen wrote: > Quoting Matthew Wilcox (2020-11-27 15:20:06) > > On Fri, Nov 27, 2020 at 03:06:24PM +0200, Joonas Lahtinen wrote: > > > Quoting ira.weiny@intel.com (2020-11-24 08:07:39) > > > > From: Ira Weiny > > > > > > > > Working through a conversion to a call such as kmap_thread() revealed > > > > many places where the pattern kmap/memcpy/kunmap occurred. > > > > > > > > Eric Biggers, Matthew Wilcox, Christoph Hellwig, Dan Williams, and Al > > > > Viro all suggested putting this code into helper functions. Al Viro > > > > further pointed out that these functions already existed in the iov_iter > > > > code.[1] > > > > > > > > Placing these functions in 'highmem.h' is suboptimal especially with the > > > > changes being proposed in the functionality of kmap. From a caller > > > > perspective including/using 'highmem.h' implies that the functions > > > > defined in that header are only required when highmem is in use which is > > > > increasingly not the case with modern processors. Some headers like > > > > mm.h or string.h seem ok but don't really portray the functionality > > > > well. 'pagemap.h', on the other hand, makes sense and is already > > > > included in many of the places we want to convert. > > > > > > > > Another alternative would be to create a new header for the promoted > > > > memcpy functions, but it masks the fact that these are designed to copy > > > > to/from pages using the kernel direct mappings and complicates matters > > > > with a new header. > > > > > > > > Lift memcpy_to_page(), memcpy_from_page(), and memzero_page() to > > > > pagemap.h. > > > > > > > > Also, add a memcpy_page(), memmove_page, and memset_page() to cover more > > > > kmap/mem*/kunmap. patterns. > > > > > > > > [1] https://lore.kernel.org/lkml/20201013200149.GI3576660@ZenIV.linux.org.uk/ > > > > https://lore.kernel.org/lkml/20201013112544.GA5249@infradead.org/ > > > > > > > > Cc: Dave Hansen > > > > Suggested-by: Matthew Wilcox > > > > Suggested-by: Christoph Hellwig > > > > Suggested-by: Dan Williams > > > > Suggested-by: Al Viro > > > > Suggested-by: Eric Biggers > > > > Signed-off-by: Ira Weiny > > > > > > > > > > > > > +static inline void memset_page(struct page *page, int val, size_t offset, size_t len) > > > > +{ > > > > + char *addr = kmap_atomic(page); > > > > + memset(addr + offset, val, len); > > > > + kunmap_atomic(addr); > > > > +} > > > > > > Other functions have (page, offset) pair. Insertion of 'val' in the middle here required > > > to take a double look during review. > > > > Let's be explicit here. Your suggested order is: > > > > (page, offset, val, len) > > > > right? I think I would prefer that to (page, val, offset, len). > > Yeah, I think that would be most consistent order. Yes as I have been reworking these I have found it odd as well. I'm going to swap it around. Been learning Coccinelle which has helped find other instances... So V2 is taking a bit of time. Thanks, Ira