From patchwork Mon Mar 16 04:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11439713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BB11913 for ; Mon, 16 Mar 2020 04:36:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D88920719 for ; Mon, 16 Mar 2020 04:36:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GgMs7KE+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D88920719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3B6D46B0005; Mon, 16 Mar 2020 00:36:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 38D146B0007; Mon, 16 Mar 2020 00:36:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27C876B0008; Mon, 16 Mar 2020 00:36:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 0FE1D6B0005 for ; Mon, 16 Mar 2020 00:36:32 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EF7DE824805A for ; Mon, 16 Mar 2020 04:36:31 +0000 (UTC) X-FDA: 76599964224.09.sand12_38fe2a9b7c22a X-Spam-Summary: 2,0,0,afd470be7dd29da9,d41d8cd98f00b204,kernelfans@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1431:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:4321:4605:5007:6119:6261:6653:6742:7514:7901:7903:9413:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12895:13846:14096:14181:14394:14687:14721:21080:21444:21451:21627:21666:21990:30012:30045:30054:30064,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: sand12_38fe2a9b7c22a X-Filterd-Recvd-Size: 5260 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 04:36:31 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id t3so7391581plz.9 for ; Sun, 15 Mar 2020 21:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j66a3s2vP+w20zjNn6qkww1MfEJEICNJLq9xqeevnk8=; b=GgMs7KE+x7u8c2D1GUcSwQOaBOyBlSMcZh5+Zn/Cql877d/Xa4BZnVC74rImQcQiza Pjnrm00Yp6zqwWC3w2/H1a0x2TlmcFf6UZI5ojLNAK2eP9KZZRMpTOtr5OMS+LI/DD0F Fbl+zMVmgP1Xq/QUOsChOQ09GEFcvynpnHOfFBjXpt7Ou38fRLiO6IPtSBF+3R0W2lJG KOxjEbXfq8L92hrL0DGarzOrB2FewqwrgURQDjTMF8EIo/L186+MMzbRmWVVF5ShYPT8 8r+fvm8XYIPuIHf6lrJQnrh/ODW7LBhBISWzabqdzXHnZhnvh37WMl+J1YB9lEGqYheY ox+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j66a3s2vP+w20zjNn6qkww1MfEJEICNJLq9xqeevnk8=; b=YFAxH5izWE3FhjmT/AVodtkKWrmtmxbB58RDkwrEtXsMPkq0d5QT52gpW5oaDY98zx IarNQaQa15d9aDC2ScUc0wIN8IbEUpUFOZsyueYpIz/eZiiwoY9Rx74cIBE0vNe3oT8a Fv0Gm9bJmjqaoSMzKd3YxUiyJXcF4AAFZBGTPCLsoNI+MjPoflwPGrXkDjP2GHkA/erO HiKTnseql3vS/S9fslCCnyHKK8Zd0qpnvt9T2FoIiaAjIkYyP8KHrtrfN5OSmVBS41id rxftK11rY5G6SOsqdEKwv48Sh9zDxovGs1PgqFc2gN5r+W9bNZ5jtHvUFcEGkgeEhipO jo3Q== X-Gm-Message-State: ANhLgQ3MY1aK5aylEMtld+TvPfcDLBtxZ6VX9maY6jNu3BoZA7ILxsh3 gwRPwQ49dNy4MXd8EsPAylGTEaw= X-Google-Smtp-Source: ADFU+vvGDBK8fWBoL3X1P0FaYHUxoUZzuCudaoA1ladHgo5FilHiD0ikM2kIDkWllOEGq+RSBlKZ+Q== X-Received: by 2002:a17:902:ab95:: with SMTP id f21mr22712206plr.188.1584333390348; Sun, 15 Mar 2020 21:36:30 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d6sm18544296pjz.39.2020.03.15.21.36.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Mar 2020 21:36:29 -0700 (PDT) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , John Hubbard , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , linux-kernel@vger.kernel.org Subject: [PATCHv6 1/3] mm/gup: rename nr as nr_pinned in get_user_pages_fast() Date: Mon, 16 Mar 2020 12:34:02 +0800 Message-Id: <1584333244-10480-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> References: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To better reflect the held state of pages and make code self-explaining, rename nr as nr_pinned. Signed-off-by: Pingfan Liu Cc: Ira Weiny Cc: Andrew Morton Cc: Mike Rapoport Cc: Dan Williams Cc: Matthew Wilcox Cc: John Hubbard Cc: "Aneesh Kumar K.V" Cc: Christoph Hellwig Cc: Shuah Khan To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Christoph Hellwig --- mm/gup.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.7.5 diff --git a/mm/gup.c b/mm/gup.c index e8aaa40..9df77b1 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2735,7 +2735,7 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, struct page **pages) { unsigned long addr, len, end; - int nr = 0, ret = 0; + int nr_pinned = 0, ret = 0; if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM | FOLL_FORCE | FOLL_PIN | FOLL_GET))) @@ -2754,25 +2754,25 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) { local_irq_disable(); - gup_pgd_range(addr, end, gup_flags, pages, &nr); + gup_pgd_range(addr, end, gup_flags, pages, &nr_pinned); local_irq_enable(); - ret = nr; + ret = nr_pinned; } - if (nr < nr_pages) { + if (nr_pinned < nr_pages) { /* Try to get the remaining pages with get_user_pages */ - start += nr << PAGE_SHIFT; - pages += nr; + start += nr_pinned << PAGE_SHIFT; + pages += nr_pinned; - ret = __gup_longterm_unlocked(start, nr_pages - nr, + ret = __gup_longterm_unlocked(start, nr_pages - nr_pinned, gup_flags, pages); /* Have to be a bit careful with return values */ - if (nr > 0) { + if (nr_pinned > 0) { if (ret < 0) - ret = nr; + ret = nr_pinned; else - ret += nr; + ret += nr_pinned; } } From patchwork Mon Mar 16 04:34:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11439715 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 375B9913 for ; Mon, 16 Mar 2020 04:36:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 02E792072A for ; Mon, 16 Mar 2020 04:36:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lY78JmHv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02E792072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3678A6B0007; Mon, 16 Mar 2020 00:36:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 318386B0008; Mon, 16 Mar 2020 00:36:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 254BC6B000A; Mon, 16 Mar 2020 00:36:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 0DC526B0007 for ; Mon, 16 Mar 2020 00:36:38 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E64E2180AD806 for ; Mon, 16 Mar 2020 04:36:37 +0000 (UTC) X-FDA: 76599964434.18.nose21_39dc6b41b5747 X-Spam-Summary: 2,0,0,4ab4a4d1199b6e2d,d41d8cd98f00b204,kernelfans@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1359:1431:1437:1535:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:4250:4385:5007:6261:6653:6742:7514:9413:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13846:14181:14394:14687:14721:21080:21251:21444:21451:21627:21666:21990:30054:30064:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: nose21_39dc6b41b5747 X-Filterd-Recvd-Size: 5335 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 04:36:37 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id dw20so3577092pjb.0 for ; Sun, 15 Mar 2020 21:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fsI1XEPfE/anfkLEVKGW8+YR1eBwmOuLro1LuQ5D+DY=; b=lY78JmHvz9cs070waBtw18dVt/JAt1JesCwcF86+QyxzR24E+YBrxUXkR/AK2qLJvP Gly4wGAIMmEX/DPr0ss4mghlm9pEQY8aQ7XLR3FpBNBXTvMk9LEh82wdwpP60IezSkiQ ozO2Z3LJzup6BX1xKCI70IFlsuQvq9xPgppJT6iSjQ0nAiFiVSwYzYTJBw/9gZvxLu/a C4HKd3s/riXihuFhxygEj2EIvgheh8XnlIVEDpDp3AbucwuOkJAJGfrPft0hUdqcHWHc nT07koP4VVT3QRn85cIOLvVQiAyUkrF4rb2LNMeTXeksIQSA4N8AqXkbD0wRXseQWYXn kddw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fsI1XEPfE/anfkLEVKGW8+YR1eBwmOuLro1LuQ5D+DY=; b=b48Co5KTRFDUKW3j9oIPvc13hmc8aldUNi6LzfzeQNbtNcfssE15NcF7X2YQF9GIM7 gd4xi3hCRFLCv6erqN2cxNxNixTA5qWxdqidwHCmSRP6nON/MUu92+Qa4g+nxo5tfHqz n3N91IeAvuqyFUpsMEM2rwp5m5yjJnn6II/mPgqKliOmI7wLA+ZnnP0/Q0d4byNszWV3 QgDFZwuTf+qqzJXLe06AlW6PEK15DNxy5Fw7WLhiT5Omj/oZPPzKsxwAa0jkW8Nbccm6 t8mOyBslTqH6SeHyuUvZUqam3Or765hcGDX2g3b3tMPS4YvDFY5s5yKrZdDtwIbOVMXc 4KhQ== X-Gm-Message-State: ANhLgQ0ebitShT2JVUxJiB5bo8fiW0pl5ttq7vsBWHM2quILK2ze6bLt MDk58irIgKQEBqhZS01UnKc0FKM= X-Google-Smtp-Source: ADFU+vulhz01sa+o+LgPj7GJ2sEvA2tjhDbL8mGwGMZalaeaW7dwYM8zUJLj3g0jTqZYwlIjEohU0Q== X-Received: by 2002:a17:90a:2:: with SMTP id 2mr23785492pja.16.1584333396201; Sun, 15 Mar 2020 21:36:36 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d6sm18544296pjz.39.2020.03.15.21.36.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Mar 2020 21:36:35 -0700 (PDT) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , John Hubbard , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , Jason Gunthorpe , linux-kernel@vger.kernel.org Subject: [PATCHv6 2/3] mm/gup: fix omission of check on FOLL_LONGTERM in gup fast path Date: Mon, 16 Mar 2020 12:34:03 +0800 Message-Id: <1584333244-10480-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> References: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: FOLL_LONGTERM is a special case of FOLL_PIN. It suggests a pin which is going to be given to hardware and can't move. It would truncate CMA permanently and should be excluded. In gup slow path, slow path, where __gup_longterm_locked->check_and_migrate_cma_pages() handles FOLL_LONGTERM, but in fast path, there lacks such a check, which means a possible leak of CMA page to longterm pinned. Place a check in try_grab_compound_head() in the fast path to fix the leak, and if FOLL_LONGTERM happens on CMA, it will fall back to slow path to migrate the page. Some note about the check: Huge page's subpages have the same migrate type due to either allocation from a free_list[] or alloc_contig_range() with param MIGRATE_MOVABLE. So it is enough to check on a single subpage by is_migrate_cma_page(subpage) Signed-off-by: Pingfan Liu Cc: Ira Weiny Cc: Andrew Morton Cc: Mike Rapoport Cc: Dan Williams Cc: Matthew Wilcox Cc: John Hubbard Cc: "Aneesh Kumar K.V" Cc: Christoph Hellwig Cc: Shuah Khan Cc: Jason Gunthorpe To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/gup.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.7.5 diff --git a/mm/gup.c b/mm/gup.c index 9df77b1..78132cf 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -89,6 +89,15 @@ static __maybe_unused struct page *try_grab_compound_head(struct page *page, int orig_refs = refs; /* + * Huge page's subpages have the same migrate type due to either + * allocation from a free_list[] or alloc_contig_range() with + * param MIGRATE_MOVABLE. So it is enough to check on a subpage. + */ + if (unlikely(flags & FOLL_LONGTERM) && + is_migrate_cma_page(page)) + return NULL; + + /* * When pinning a compound page of order > 1 (which is what * hpage_pincount_available() checks for), use an exact count to * track it, via hpage_pincount_add/_sub(). From patchwork Mon Mar 16 04:34:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11439717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52DEE913 for ; Mon, 16 Mar 2020 04:36:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 059A52071C for ; Mon, 16 Mar 2020 04:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uHezxfB6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 059A52071C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 367B86B0008; Mon, 16 Mar 2020 00:36:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 347236B000A; Mon, 16 Mar 2020 00:36:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27BA66B000C; Mon, 16 Mar 2020 00:36:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 11E126B0008 for ; Mon, 16 Mar 2020 00:36:44 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D9C55181AEF15 for ; Mon, 16 Mar 2020 04:36:43 +0000 (UTC) X-FDA: 76599964686.18.rate79_3abeac6d40043 X-Spam-Summary: 2,0,0,30b40539b4d30282,d41d8cd98f00b204,kernelfans@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1431:1437:1535:1543:1711:1730:1747:1777:1792:1801:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:3871:4117:4321:4605:5007:6119:6261:6653:6742:7514:9413:10004:11026:11473:11657:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13846:14096:14181:14394:14687:14721:21080:21251:21444:21451:21611:21627:21666:21990:30054:30056:30064:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: rate79_3abeac6d40043 X-Filterd-Recvd-Size: 6265 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 04:36:43 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id b22so2997288pgb.6 for ; Sun, 15 Mar 2020 21:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x2aIrmW9cjK3AgpyGIiS7LfjEbJ0vHmekSq11XjW84U=; b=uHezxfB6KVcV9YYBFik9200F1Q4y/ehcQzB5jf54vlptqSWdZ3jJLn4xNpPBYgwIlK vmSD8ooYCjlXZloxDZHYtzylV1gGJ7By8PpRCjRyUT4PNvfQMXKI6Tgv2pAYhFtIyGdV lfhXu66n8BEGPws4QUjrFyfabLS8vrI4UTvtS0Dpu5RYuZBWgFsN+tumWcL0cj9eMwP1 lQXV2zUL0UF78XXWQ8nqlc9Y9FAIN6u4gCw/N+4NGEi8kfcvzzU7BADywDAeRhFXu89d sKs8K0FFI9UeKscyTdBCyTIqN0HHULytKd8fplktKMe4unwI7B7lmFLOacuvBVqkPh4V rpNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x2aIrmW9cjK3AgpyGIiS7LfjEbJ0vHmekSq11XjW84U=; b=X1+7DsmkxWXkLS62j9sUdHZXWKRtreOTnjKAYsI7Lqy0bVAlqFhJ+By+qwQTPx3wP6 4Q8FP60uu5qc1n4dd9tzI2Xz95d4ImKIC86CN/RlU2XN36wlhv0BJGoqJoGvXGhw0anZ hdgcBxxSvoSNt6w6VflbAzhw38s2k7vrehitGy3ARDAdQ33kWHz4fBtuGzhcCIFIV1AM FZPuS05y0KwLyCLoDHhrpAxzzm1qTAYI+ZsvXdLIvjmerxWxM73FrOQzEMdWNs6ul0cR LIFqyHJgEIIH9i2rvBSCMj/y6I2lztFrD9YRnu5lmp9lgOAfKMzbz7FpgvsvXZBOwP1r 0sSw== X-Gm-Message-State: ANhLgQ3D51vLa+bW1oGfI4SLOqw1DsFxsbvl/dKehHr21YUmLXNohgNK uLF9QvwB+dQbku5Wm1uqJ5oCeKk= X-Google-Smtp-Source: ADFU+vvD7ZY12Fv5AuWSMX8HBSYi+c/pA6BWamHOhmpp3/wxLvuyqf0jdFOYO2rfworbjAz/j+AM9w== X-Received: by 2002:a63:5859:: with SMTP id i25mr24389370pgm.74.1584333402141; Sun, 15 Mar 2020 21:36:42 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d6sm18544296pjz.39.2020.03.15.21.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Mar 2020 21:36:41 -0700 (PDT) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , John Hubbard , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , Alexander Duyck , linux-kernel@vger.kernel.org Subject: [PATCHv6 3/3] mm/gup_benchemark: add LONGTERM_BENCHMARK test in gup fast path Date: Mon, 16 Mar 2020 12:34:04 +0800 Message-Id: <1584333244-10480-4-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> References: <1584333244-10480-1-git-send-email-kernelfans@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Introduce a PIN_FAST_LONGTERM_BENCHMARK ioctl to test longterm pin in gup fast path. Signed-off-by: Pingfan Liu Cc: Ira Weiny Cc: Andrew Morton Cc: Mike Rapoport Cc: Dan Williams Cc: Matthew Wilcox Cc: John Hubbard Cc: "Aneesh Kumar K.V" Cc: Christoph Hellwig Cc: Shuah Khan Cc: Alexander Duyck To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/gup_benchmark.c | 7 +++++++ tools/testing/selftests/vm/gup_benchmark.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) -- 2.7.5 diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c index be690fa..09fba20 100644 --- a/mm/gup_benchmark.c +++ b/mm/gup_benchmark.c @@ -10,6 +10,7 @@ #define GUP_BENCHMARK _IOWR('g', 3, struct gup_benchmark) #define PIN_FAST_BENCHMARK _IOWR('g', 4, struct gup_benchmark) #define PIN_BENCHMARK _IOWR('g', 5, struct gup_benchmark) +#define PIN_FAST_LONGTERM_BENCHMARK _IOWR('g', 6, struct gup_benchmark) struct gup_benchmark { __u64 get_delta_usec; @@ -101,6 +102,11 @@ static int __gup_benchmark_ioctl(unsigned int cmd, nr = get_user_pages_fast(addr, nr, gup->flags, pages + i); break; + case PIN_FAST_LONGTERM_BENCHMARK: + nr = get_user_pages_fast(addr, nr, + gup->flags | FOLL_LONGTERM, + pages + i); + break; case GUP_LONGTERM_BENCHMARK: nr = get_user_pages(addr, nr, gup->flags | FOLL_LONGTERM, @@ -166,6 +172,7 @@ static long gup_benchmark_ioctl(struct file *filep, unsigned int cmd, case GUP_BENCHMARK: case PIN_FAST_BENCHMARK: case PIN_BENCHMARK: + case PIN_FAST_LONGTERM_BENCHMARK: break; default: return -EINVAL; diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c index 43b4dfe..f024ff3 100644 --- a/tools/testing/selftests/vm/gup_benchmark.c +++ b/tools/testing/selftests/vm/gup_benchmark.c @@ -21,6 +21,7 @@ /* Similar to above, but use FOLL_PIN instead of FOLL_GET. */ #define PIN_FAST_BENCHMARK _IOWR('g', 4, struct gup_benchmark) #define PIN_BENCHMARK _IOWR('g', 5, struct gup_benchmark) +#define PIN_FAST_LONGTERM_BENCHMARK _IOWR('g', 6, struct gup_benchmark) /* Just the flags we need, copied from mm.h: */ #define FOLL_WRITE 0x01 /* check pte is writable */ @@ -44,7 +45,7 @@ int main(int argc, char **argv) char *file = "/dev/zero"; char *p; - while ((opt = getopt(argc, argv, "m:r:n:f:abtTLUuwSH")) != -1) { + while ((opt = getopt(argc, argv, "m:r:n:f:abtTlLUuwSH")) != -1) { switch (opt) { case 'a': cmd = PIN_FAST_BENCHMARK; @@ -67,6 +68,9 @@ int main(int argc, char **argv) case 'T': thp = 0; break; + case 'l': + cmd = PIN_FAST_LONGTERM_BENCHMARK; + break; case 'L': cmd = GUP_LONGTERM_BENCHMARK; break;