From patchwork Wed Jun 28 21:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13296393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1888EB64DA for ; Wed, 28 Jun 2023 21:53:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A80B8D0008; Wed, 28 Jun 2023 17:53:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 058548D0001; Wed, 28 Jun 2023 17:53:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9F428D0008; Wed, 28 Jun 2023 17:53:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CC0328D0001 for ; Wed, 28 Jun 2023 17:53:26 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A8D211A030B for ; Wed, 28 Jun 2023 21:53:26 +0000 (UTC) X-FDA: 80953508412.21.84BE2E2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 6FBECC0023 for ; Wed, 28 Jun 2023 21:53:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KeboY+yW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687989203; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; b=Jn11f6bAlphf/J+xebsfidABl2WedJCfMYWWbVAD8AsMoNTQKYDV7FYt8V9SrSawuZnkFS o3trCo68OaNtZyC5jFq4Y73q4p104AeMzUBKpex4Dyn+PzUDkel5Pv15EQdLIalyjOI0Ty LIAiIXqUJ6sgfDcv8PjB1X2kgh/sTNo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KeboY+yW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687989203; a=rsa-sha256; cv=none; b=0OS0QhtzuWOLsxPBWl1oUICWrt+NENXAJ2f+d0PA2xRo/EmFOwd4HSzTc06sbb4ybTZwda uwybgIkaYt5TZeGENCmIMVkN5SuMhlV6hQMcxTe+gLV0cIKYetyk5WArcGsY9GGKXFqaCe jrxvHBDhzhn4kq+oP9ejAImCG8qLbOI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687989202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; b=KeboY+yWnMKPcw2c9tAxR3tXXzaV350QaS30sgj7axrBoxG85ZTstcCfZmBmz/o0rM5vA8 2rgQmsKBs5+E0i+G2kuCvmUrakR8NcS+Qt5pc0Yv3nz5LoOK60fPUtE9W84zZOrL+1P7ht +HEI33J9VrqWaGGFw53Cyu9qIlj+9nM= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-RVyHkiDJPFOXqajzmPxoTg-1; Wed, 28 Jun 2023 17:53:20 -0400 X-MC-Unique: RVyHkiDJPFOXqajzmPxoTg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4009ad15222so27711cf.1 for ; Wed, 28 Jun 2023 14:53:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687989198; x=1690581198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; b=ZBcbwG2VFSZPVlk/QXDvfqG0JhfB74wGE2Zzu+nXVGzJU8w4V6bOKKjNkz50cTblxr LgYBWHpXdNMBgHnkORlfQrkTS1Okl4LodllAbZXdrg0dqQFgBx6foh+VWeYvJDeWGLpt iYWO/zMK3si4s6lQRGOfv1dcSglj8JwkLq/T+4l+l83RC/BN/EUB7n0EdO9P4Wr/0zS6 j1VZoBbNd+gwDB9KLslQLDPJGmnhYAnzDyPi0JIVEjAERtw10JxeRYy7Mzgqgo/hq2em i6tAnYpK6zomBV2zY5Pml45m5CS3XDAO0oH1feJPMloTCQ3bX50PX2kd8PV17efaIOl7 TTcQ== X-Gm-Message-State: AC+VfDxsXUGak9PqnnR/XhcJrXytAz0sk+tHxcx2/h2o8WisDXmwhlM2 POx/NxGY2+eI9PrQQxye1paeyuRcozbNcyxT4TRxiEFVpGOFc/4aDitSQm4727aLAYNMrwC0Rpn BVFif42IboAy0eOYjhzv32EZc5zF4pgd0GzERibx7b+U8EE2ppjJ+owFj9dLJFzoEv2Ty X-Received: by 2002:a05:6214:301a:b0:635:da19:a67f with SMTP id ke26-20020a056214301a00b00635da19a67fmr13098208qvb.1.1687989198128; Wed, 28 Jun 2023 14:53:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bWthzbIpu8brAzYWFel0vezukPFHw5JtwGCHRd23ZlsKMqKd/fjN3mRP22Dyi1lIzaJO53Q== X-Received: by 2002:a05:6214:301a:b0:635:da19:a67f with SMTP id ke26-20020a056214301a00b00635da19a67fmr13098180qvb.1.1687989197705; Wed, 28 Jun 2023 14:53:17 -0700 (PDT) Received: from x1n.. (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id p3-20020a0cfac3000000b00631fea4d5bcsm6277797qvo.95.2023.06.28.14.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:53:17 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , "Kirill A . Shutemov" , Andrew Morton , Andrea Arcangeli , Mike Rapoport , John Hubbard , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Yang Shi , James Houghton , Jason Gunthorpe , Lorenzo Stoakes , Hugh Dickins , peterx@redhat.com Subject: [PATCH v4 4/8] mm/gup: Cleanup next_page handling Date: Wed, 28 Jun 2023 17:53:06 -0400 Message-ID: <20230628215310.73782-5-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628215310.73782-1-peterx@redhat.com> References: <20230628215310.73782-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 6FBECC0023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gxaoc6kjtk9shmgpw1f7xi44puywj739 X-HE-Tag: 1687989203-197959 X-HE-Meta: U2FsdGVkX1/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EW2tctiFP/9T6WXSt+tIZJcETWuL3Xc4SKFs5l0gvJyR82DCy7DOUTugpLP+cQMhSGncz/gkXoKlUgrlV35GUrvZ6xd5VCXm6VNGgveYlLODb7VjPwy4cDJAeiByvjD1qkG3zOiauIDmz/Rz/Y/eV6LNGQF1MXxwhC+gvVBJmMz0aiqcVp+aQ9llIaLoDJRnCO7w8xuvQrjjVl1sIENZeDaB2DekT4FtzhtMBkd4VqAxiRRInKJoxrdpaqBNBiMWRGXgcAGbGQUctwZu+hB82aBARsg1OqL2phJAGE5Mzui292O66AYAtxD2vNg8sasWU2lO1Gipwh4hvEPsA+66INadflTKxA6NnZOsm/0vwMgowdqXuQC578c4NJYbHo= 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: The only path that doesn't use generic "**pages" handling is the gate vma. Make it use the same path, meanwhile tune the next_page label upper to cover "**pages" handling. This prepares for THP handling for "**pages". Reviewed-by: Lorenzo Stoakes Acked-by: David Hildenbrand Signed-off-by: Peter Xu --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 1e2e23084f3c..5af1be81390b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1124,7 +1124,7 @@ static long __get_user_pages(struct mm_struct *mm, if (!vma && in_gate_area(mm, start)) { ret = get_gate_page(mm, start & PAGE_MASK, gup_flags, &vma, - pages ? &pages[i] : NULL); + pages ? &page : NULL); if (ret) goto out; ctx.page_mask = 0; @@ -1194,19 +1194,18 @@ static long __get_user_pages(struct mm_struct *mm, ret = PTR_ERR(page); goto out; } - - goto next_page; } else if (IS_ERR(page)) { ret = PTR_ERR(page); goto out; } +next_page: if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); ctx.page_mask = 0; } -next_page: + page_increm = 1 + (~(start >> PAGE_SHIFT) & ctx.page_mask); if (page_increm > nr_pages) page_increm = nr_pages;