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
| ||
|
Message-ID: <20191212081917.1264184-3-jhubbard@nvidia.com> Date: Thu, 12 Dec 2019 00:18:54 -0800 From: John Hubbard <jhubbard@...dia.com> To: Andrew Morton <akpm@...ux-foundation.org> CC: Al Viro <viro@...iv.linux.org.uk>, Alex Williamson <alex.williamson@...hat.com>, Benjamin Herrenschmidt <benh@...nel.crashing.org>, Björn Töpel <bjorn.topel@...el.com>, Christoph Hellwig <hch@...radead.org>, Dan Williams <dan.j.williams@...el.com>, Daniel Vetter <daniel@...ll.ch>, Dave Chinner <david@...morbit.com>, David Airlie <airlied@...ux.ie>, "David S . Miller" <davem@...emloft.net>, Ira Weiny <ira.weiny@...el.com>, Jan Kara <jack@...e.cz>, Jason Gunthorpe <jgg@...pe.ca>, Jens Axboe <axboe@...nel.dk>, Jonathan Corbet <corbet@....net>, Jérôme Glisse <jglisse@...hat.com>, Magnus Karlsson <magnus.karlsson@...el.com>, Mauro Carvalho Chehab <mchehab@...nel.org>, Michael Ellerman <mpe@...erman.id.au>, Michal Hocko <mhocko@...e.com>, Mike Kravetz <mike.kravetz@...cle.com>, Paul Mackerras <paulus@...ba.org>, Shuah Khan <shuah@...nel.org>, Vlastimil Babka <vbabka@...e.cz>, <bpf@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>, <kvm@...r.kernel.org>, <linux-block@...r.kernel.org>, <linux-doc@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>, <linux-media@...r.kernel.org>, <linux-rdma@...r.kernel.org>, <linuxppc-dev@...ts.ozlabs.org>, <netdev@...r.kernel.org>, <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>, John Hubbard <jhubbard@...dia.com>, Christoph Hellwig <hch@....de> Subject: [PATCH v10 02/25] mm/gup: move try_get_compound_head() to top, fix minor issues An upcoming patch uses try_get_compound_head() more widely, so move it to the top of gup.c. Also fix a tiny spelling error and a checkpatch.pl warning. Reviewed-by: Christoph Hellwig <hch@....de> Reviewed-by: Jan Kara <jack@...e.cz> Reviewed-by: Ira Weiny <ira.weiny@...el.com> Signed-off-by: John Hubbard <jhubbard@...dia.com> --- mm/gup.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index f764432914c4..3ecce297a47f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -29,6 +29,21 @@ struct follow_page_context { unsigned int page_mask; }; +/* + * Return the compound head page with ref appropriately incremented, + * or NULL if that failed. + */ +static inline struct page *try_get_compound_head(struct page *page, int refs) +{ + struct page *head = compound_head(page); + + if (WARN_ON_ONCE(page_ref_count(head) < 0)) + return NULL; + if (unlikely(!page_cache_add_speculative(head, refs))) + return NULL; + return head; +} + /** * put_user_pages_dirty_lock() - release and optionally dirty gup-pinned pages * @pages: array of pages to be maybe marked dirty, and definitely released. @@ -1807,20 +1822,6 @@ static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start, } } -/* - * Return the compund head page with ref appropriately incremented, - * or NULL if that failed. - */ -static inline struct page *try_get_compound_head(struct page *page, int refs) -{ - struct page *head = compound_head(page); - if (WARN_ON_ONCE(page_ref_count(head) < 0)) - return NULL; - if (unlikely(!page_cache_add_speculative(head, refs))) - return NULL; - return head; -} - #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, unsigned int flags, struct page **pages, int *nr) -- 2.24.0
Powered by blists - more mailing lists