lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 3 Dec 2020 10:25:05 -0800
From:   Ira Weiny <ira.weiny@...el.com>
To:     Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>
Cc:     Matthew Wilcox <willy@...radead.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Dave Hansen <dave.hansen@...el.com>,
        Christoph Hellwig <hch@...radead.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Al Viro <viro@...iv.linux.org.uk>,
        Eric Biggers <ebiggers@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Luis Chamberlain <mcgrof@...nel.org>,
        Patrik Jakobsson <patrik.r.jakobsson@...il.com>,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        David Howells <dhowells@...hat.com>, Chris Mason <clm@...com>,
        Josef Bacik <josef@...icpanda.com>,
        David Sterba <dsterba@...e.com>,
        Steve French <sfrench@...ba.org>,
        Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <yuchao0@...wei.com>,
        Nicolas Pitre <nico@...xnic.net>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Brian King <brking@...ibm.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jérôme Glisse <jglisse@...hat.com>,
        Kirti Wankhede <kwankhede@...dia.com>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 01/17] mm/highmem: Lift memcpy_[to|from]_page and
 memset_page to core

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@...el.com (2020-11-24 08:07:39)
> > > > From: Ira Weiny <ira.weiny@...el.com>
> > > > 
> > > > 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 <dave.hansen@...el.com>
> > > > Suggested-by: Matthew Wilcox <willy@...radead.org>
> > > > Suggested-by: Christoph Hellwig <hch@...radead.org>
> > > > Suggested-by: Dan Williams <dan.j.williams@...el.com>
> > > > Suggested-by: Al Viro <viro@...iv.linux.org.uk>
> > > > Suggested-by: Eric Biggers <ebiggers@...nel.org>
> > > > Signed-off-by: Ira Weiny <ira.weiny@...el.com>
> > > 
> > > <SNIP>
> > > 
> > > > +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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ