From patchwork Tue Jun 13 21:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13279237 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 EB25FEB64D7 for ; Tue, 13 Jun 2023 21:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FA656B0080; Tue, 13 Jun 2023 17:54:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AACE8E0002; Tue, 13 Jun 2023 17:54:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34BF56B0082; Tue, 13 Jun 2023 17:54:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 27FBA6B0080 for ; Tue, 13 Jun 2023 17:54:10 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ED67C1C81FE for ; Tue, 13 Jun 2023 21:54:09 +0000 (UTC) X-FDA: 80899078218.07.60E1D26 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id CD9964001C for ; Tue, 13 Jun 2023 21:54:07 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CtL1Lr3u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1686693247; 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=P+etnUAQLV4NR7aCVrXKWbeziVnwWOuYfO0O45I26FE=; b=Op2lmHeSO/EZsnAUdh6A9/tf2AqOPXTsiitcf21m9wsv89QBv58xyC9nN+yFOvW6Z/dotS UcocOY7m90mDTw4tOwMvZ8Ftr+FpaEjdVkDr4XFk/PZviVO24qNRYMNdk0ZJ523xepWhcI pFxTShClttmQ1/J1OwY08FX7xcyIFqo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CtL1Lr3u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1686693247; a=rsa-sha256; cv=none; b=k+Su2EJ45fbZ/5tZLkY78xSvFEu0OfblMoFSbldp7edfc8rO1qqEYELDVe4U8aee11Jml4 gAFOV8NYUDnvqWEYE3bGWis0amwmVH8gE79ZtIlJvMiyXMoEUAFxs9/8Y/c06wLvwOpB2k Syxaf5uSlmnKgdnpkmdkVjpN0toT0Cg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686693247; 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=P+etnUAQLV4NR7aCVrXKWbeziVnwWOuYfO0O45I26FE=; b=CtL1Lr3us30LUzvnAIEiiyHQrjEYxCevmJ3kfMhuQDDGoaND/YK4b6kXU68MC+07Oh8HOU mxcNT+nD4WqYSx5qKn8ILFNUrzaOhve5SJgJYxxWjYVZYDHDpeFurxamfJbFt4+EdFZ3V6 7vdxy5TbaHYjbv+2z1KnXbx2gHBPcz4= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-PcVpfU0WNSiyLCF0cUkE1g-1; Tue, 13 Jun 2023 17:54:04 -0400 X-MC-Unique: PcVpfU0WNSiyLCF0cUkE1g-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f8283a3a7aso13777241cf.1 for ; Tue, 13 Jun 2023 14:54:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686693242; x=1689285242; 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=P+etnUAQLV4NR7aCVrXKWbeziVnwWOuYfO0O45I26FE=; b=LKHvn2l8bOYep7kYd0NRm4FAvsjAbzdrCz5isxxQwYWNYgs10Pk5fbZRrA5cXGqXQi jc6UqjhZkXbphQinKHXfDUH6r48hP6K3hThBsw7XwJq2wQXeR0gPU9+bwuFVM6E6lYUD ugihVWlAykxN6ujRC6Xrl5nIlCdsuSQRvaxTPofoIl+hFzuKb1Wg7H/XD/b8qLmpZGn6 DavxEh2sFt8cfCyF7MYq/FLPUMnNN+2LIBbH/JhqMqJCR6UgXqoTKHgNePmonm53/SGJ vZQ7j6i0m1OIYIjjMnTx/t169s48inKSUGI+rADniyhXBIrdLbZEU7Hjsa0xwkgqT4/m aAPw== X-Gm-Message-State: AC+VfDyy/LwjKrl65rRpFwn5JPwhPPSBQeRpTW81/Dm6z8X86jDg0MBR VCFCUbIpp4Bn5NKomUDdO6lW/JUx3IhcABlKz9kiL8qHTxRAaFv5Co/fs7Fuy9DlcQ0N0DFRuxQ 3wztefrEvebo= X-Received: by 2002:a05:622a:288:b0:3e3:c889:ecf9 with SMTP id z8-20020a05622a028800b003e3c889ecf9mr18140058qtw.1.1686693242157; Tue, 13 Jun 2023 14:54:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63MJGi+Hqlnli2JVzskYtPLZcbne7s+MQZPsj8TgX9mGHr+EIA5dm91k8Xq113ELiGPseUlA== X-Received: by 2002:a05:622a:288:b0:3e3:c889:ecf9 with SMTP id z8-20020a05622a028800b003e3c889ecf9mr18140043qtw.1.1686693241922; Tue, 13 Jun 2023 14:54:01 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id fz24-20020a05622a5a9800b003f9bccc3182sm4522330qtb.32.2023.06.13.14.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 14:54:01 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Andrea Arcangeli , John Hubbard , Mike Rapoport , David Hildenbrand , Vlastimil Babka , peterx@redhat.com, "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins Subject: [PATCH 5/7] mm/gup: Cleanup next_page handling Date: Tue, 13 Jun 2023 17:53:44 -0400 Message-Id: <20230613215346.1022773-6-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230613215346.1022773-1-peterx@redhat.com> References: <20230613215346.1022773-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: CD9964001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jskjfo7e4hkazgo4y3w38yznq6w8ioam X-HE-Tag: 1686693247-347603 X-HE-Meta: U2FsdGVkX1/cA+gAWQApCf8Px8co6fvKJr28U7V04TPWZWenYFUZ48tirCdl1IyyFCcQFv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x0rPWcwId8JkLXCnMb9K8G2KmOwVo9pMyb0HXzyTkEAYK3+7LOUttR9Osc8YQEEGqZyV2FBK0+lYHU/jBIpudx/ugRKVqoSwp7wjYlFc+QOdN7UF8/LyQjHLNqHWhR9WdSa8Jw9mJS0bc36CTPznVMwUEmreWXXYU7z/7Me6Bx67ayjUrz3Mo33Cps2NUaFwnbppxAkdecMn+/KkZHzOmdQG+mZ8WHkOlF21o4T/yReRMNMoC6J0mdQw7Akz4jfwQfv+Q2JyFXg== 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". Signed-off-by: Peter Xu Reviewed-by: Lorenzo Stoakes --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 8d59ae4554e7..a2d1b3c4b104 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1135,7 +1135,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; @@ -1205,19 +1205,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;