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: 107571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp846554vqr; Tue, 13 Jun 2023 14:58:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DAPAgB9wRkHHtX3SbIXI90e65Jp7MP5sjQ4PST9vqe/goJU2Z6a+mFzaU//VxddlLpP4+ X-Received: by 2002:a17:907:a49:b0:961:272d:bdb9 with SMTP id be9-20020a1709070a4900b00961272dbdb9mr12749544ejc.43.1686693517778; Tue, 13 Jun 2023 14:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686693517; cv=none; d=google.com; s=arc-20160816; b=xsobbnnzRsvGge96SBCj/LuPllXT/BAtm2sbB3X4mSCmECVYM1UtBwzdagLc5XH8Ss S/62mzcCGBjb4AV80c75KF5bjmEYk5LLME0hnR58xyHF3wA2pIH9zMdPpoVCI6EccNC2 /5LERwWiXO+GBzKM9OWX+jxyt2vbs59hzGnJrlS0C1RkF9Gl8SCECL6MFaKfsIb12hmV j64/cG/doB8YcfZXNl7s/H/mpKwGXtKWLFpUrbAqtr+1jhL92LP4Zo5HQzOQFkS7Ar0o knz5erDtVDaDDLBAFjyskx1ZvesmwVyCz2FZbBi6Ewxmey04Z0AIPcGbTokH8d/vpma9 WE5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P+etnUAQLV4NR7aCVrXKWbeziVnwWOuYfO0O45I26FE=; b=ODFl71AyfZjj6+aKQnjwUkI+rrjdstcWkOG0qHi67Aft079u3XeDO17qzvHDq1Y+lO dfx8umPJWxbzZM6S9O2eSPHIKj2V7jB3+1BuT/UTDJBTNv77slcrgOuX4iIKpmxNH7TK Rdh8/d1av3znnwC79zQuYCZVJmo8SB+RNC6Y0psrqvcuHwm7wo8t0zx/aJ6Uw2rBjuwP rPxmvBve0lPTeiuFu+eF+u23s0fP1PKE6WN7rzkaUXzyJJinsWymSMzL5OJISQjP4S/G 1Zs1f/otocCDcu7pMpT5ok92QY4lLbf92SZZiV3qge4ZskFGwQcMGd+m7pznxhk7XTZs y1Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X+LsFmVu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020a1709062bd000b00977f2554dc1si7175532ejg.831.2023.06.13.14.58.12; Tue, 13 Jun 2023 14:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X+LsFmVu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234251AbjFMVzA (ORCPT + 99 others); Tue, 13 Jun 2023 17:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235185AbjFMVyo (ORCPT ); Tue, 13 Jun 2023 17:54:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5079D1BD3 for ; Tue, 13 Jun 2023 14:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686693245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+etnUAQLV4NR7aCVrXKWbeziVnwWOuYfO0O45I26FE=; b=X+LsFmVuAb+J+kUzExri4EsyTs8FY9mvGRF58p10AYaZDRP6HlZufjx/wGrP8QlUs0hDjk s+yaGIGjnTTyvsFtDMXExoH/SZfWqc+qqh7EvLiFEq6EYcBUrPynVFpdJ/GllSfIaRgr8I 0T84nMwlxCHtkeG4DY1487XMtTU1atk= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-N_KwzfysNCSjx2fTyoimkA-1; Tue, 13 Jun 2023 17:54:03 -0400 X-MC-Unique: N_KwzfysNCSjx2fTyoimkA-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3f8283a3a7aso13777301cf.1 for ; Tue, 13 Jun 2023 14:54:03 -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=AYS6A7xHwr8AUU90mM8VRAkicmlyjemGPL2s8RmgAHlYr/N0xxUZyroi4xyxEO1RNp GumhL83+lWFlQYQIi+B6nRXeFU2Q9sx2siGBcYzUh3XAFJuqRcXx7D5VZyHdm0baEYj8 T/JU6T+mYYQJdT9jtjMVI2oiZu9kjzA0/LySE1K/kIVfvVNlxjUXiNhJw2VyE4UtfNpU S1WuXsVLDpkBGD4KMMeKuo5j4GKsOlDHZIYJPzM7HKddeDyKzdIbZRIAiojX+8Jjn+n0 3HI0bp4tnKYhuAXvx3dTj/Az9JeUcIO0D/aL1INzQoq0hh5jVWAEgzdAO6rWvByEQhLm Ytgw== X-Gm-Message-State: AC+VfDxSnCdJ2LrH383rr3XvkN6kC2DjjiSvzitywKhqrJ0512CJBXbr tP0AlY4S+5cyqfUpVH2XDAlyQkZ31rFF/e1Nh/YDtkimAIuWFThb29TQ63Oj0pUHgymuqQgmjJ+ AiyWuFRGAxA3w+mabYFobV+DajCxa3uYBD+gmOzibKYNEi63cOP1dIOOwYxeMu3z8n8LC6UHCIO pbDQlB2A== X-Received: by 2002:a05:622a:288:b0:3e3:c889:ecf9 with SMTP id z8-20020a05622a028800b003e3c889ecf9mr18140069qtw.1.1686693242232; Tue, 13 Jun 2023 14:54:02 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768626341943253041?= X-GMAIL-MSGID: =?utf-8?q?1768626341943253041?= 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;