From patchwork Sat Oct 31 19:46:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 317335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 178CFC56202 for ; Sat, 31 Oct 2020 19:46:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA92820706 for ; Sat, 31 Oct 2020 19:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604173575; bh=sN0QqVjDOT1HA92M+OekPMnfmTpqfZbsUGQ9yPWqfUA=; h=Date:From:To:Subject:List-ID:From; b=LAsQAQFL+737vodBIHTVgq/1Xy77hTCnfA+T18OrwtbEo+6cSS5IzXReqtBCngfiz HImZ4gmul9/Pu+qqxfUmDsSxFettloqhxMSZimEjDfigb6APhims4JTDw8Uef75Sa8 ub6HYQfozbxi+VYaycODX1m1UCT2/NlZaUmVPrAs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728457AbgJaTqO (ORCPT ); Sat, 31 Oct 2020 15:46:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbgJaTqM (ORCPT ); Sat, 31 Oct 2020 15:46:12 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 984F5206E3; Sat, 31 Oct 2020 19:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604173571; bh=sN0QqVjDOT1HA92M+OekPMnfmTpqfZbsUGQ9yPWqfUA=; h=Date:From:To:Subject:From; b=bgWyw0eT+eRlS74vJ3s63uCPei4MLx6BPiIveLMvg0TtF6M5KSKnDDAXAdtsLYNoO /TyjbFDiSrdYAXF7MCowluwmh4zNFqy3UV/kFHUBKWlHTrj1ITnypAWN1agnvIFoI2 d8bXske8ZcY0hW+wfMnfUfkznZhhr6IBgAZXfCag= Date: Sat, 31 Oct 2020 12:46:11 -0700 From: akpm@linux-foundation.org To: aneesh.kumar@linux.ibm.com, imbrenda@linux.ibm.com, ira.weiny@intel.com, jack@suse.cz, jgg@nvidia.com, jhubbard@nvidia.com, mm-commits@vger.kernel.org, stable@vger.kernel.org Subject: + mm-gup-use-unpin_user_pages-in-check_and_migrate_cma_pages.patch added to -mm tree Message-ID: <20201031194611.slgOhggX7%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: mm/gup: use unpin_user_pages() in check_and_migrate_cma_pages() has been added to the -mm tree. Its filename is mm-gup-use-unpin_user_pages-in-check_and_migrate_cma_pages.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-gup-use-unpin_user_pages-in-check_and_migrate_cma_pages.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-use-unpin_user_pages-in-check_and_migrate_cma_pages.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jason Gunthorpe Subject: mm/gup: use unpin_user_pages() in check_and_migrate_cma_pages() When FOLL_PIN is passed to __get_user_pages() the page list must be put back using unpin_user_pages() otherwise the page pin reference persists in a corrupted state. Link: https://lkml.kernel.org/r/0-v1-976effcd4468+d4-gup_cma_fix_jgg@nvidia.com Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages") Signed-off-by: Jason Gunthorpe Cc: Aneesh Kumar K.V Cc: Claudio Imbrenda Cc: Ira Weiny Cc: Jan Kara Cc: John Hubbard Cc: Signed-off-by: Andrew Morton --- mm/gup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/mm/gup.c~mm-gup-use-unpin_user_pages-in-check_and_migrate_cma_pages +++ a/mm/gup.c @@ -1647,8 +1647,11 @@ check_again: /* * drop the above get_user_pages reference. */ - for (i = 0; i < nr_pages; i++) - put_page(pages[i]); + if (gup_flags & FOLL_PIN) + unpin_user_pages(pages, nr_pages); + else + for (i = 0; i < nr_pages; i++) + put_page(pages[i]); if (migrate_pages(&cma_page_list, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_CONTIG_RANGE)) {