Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1764288rwd; Tue, 13 Jun 2023 13:59:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qq4gNNFFbVyrf16dV8Uni0mBgzQCruUg9A+r14EE2ujqz+Cy3QZK03ti4G1FHvSkvSxjN X-Received: by 2002:a17:907:1c1f:b0:982:21a1:c4e0 with SMTP id nc31-20020a1709071c1f00b0098221a1c4e0mr6084232ejc.56.1686689977419; Tue, 13 Jun 2023 13:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686689977; cv=none; d=google.com; s=arc-20160816; b=D4AIvi/oUofSKaCeXL+XkfExVMVKL2HSKGArFzOE7M2q+yAuhq/DSM6Cg4uZX/uc3A JuRmLO5CB/WtVyXtJ91VtEmSW5FGNLbYPc+CbLQJTWVcchb3jp19/dYOw96E8vpzbrjz LvQ7zaSkUsu+Pz7uQZWNtQxkd9SYigN66/nHAxnf2tA08WLh5DrjnICb6XbdnhoxtIPg hI0GxgsIP3OpOVlH/HZDHxqfCvsV9/Xy2gCsC2UPioJx+PWuxg1UuDx0UAwmq2PC9Vlf /qB9Tr6wNMu6U/fPDBLS63PXjHFP7gp3kk54RcBEoSX7NVlAyKLe1I0udvs8s75YWtEy ymzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OrA3nYHV2kwtLgffjhCAj6EA13cg0ZzpKIffYzucd0E=; b=kKM+tP3LWSg2dBC97xoz1XyXMgt/0N6Eas77557tVMY2sfh0hwlVy3RtlINfFPtRE7 /5FcDdPJMtwans+iDxuLVrDYgKjE61zgIs8/Cj8kPTjSMfWT+uxj1QrWdyhDu7YyzVFC a+q2DpbK5TR21Y+nMX+sGHHlEVhJiLEbVlbdW4tfGd60xRFZ+G88KlIRSoNVhnautGyc H1dTi+T+NuYluJwPD2f8Pz50hlFHDccniUTCXH7jXxgb126tECupbwLC6ttTqrCStHjL JY2Q+vMOcJ+P6fEdUYS6zvP5XMktWBLy+m+r5ebc6ZokNyMSwE6aTihPRH2ST5SgU0nb UjzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=i02TPBLc; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a1709063c4e00b009788ec72d2fsi7797261ejg.620.2023.06.13.13.59.12; Tue, 13 Jun 2023 13:59: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=@infradead.org header.s=casper.20170209 header.b=i02TPBLc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232792AbjFMU3e (ORCPT + 99 others); Tue, 13 Jun 2023 16:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbjFMU3b (ORCPT ); Tue, 13 Jun 2023 16:29:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA86135 for ; Tue, 13 Jun 2023 13:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OrA3nYHV2kwtLgffjhCAj6EA13cg0ZzpKIffYzucd0E=; b=i02TPBLcl/8+jUdcAWBPDrs58l XaKvEIeljpEDQ8Fguis2DrCIlAj+XXtPocmj0DR+MUnQj/s54891p80EczYtu3AgZipgx4rD21vLy tLgOv5x0kIoUj69wiQcHxvfxj4rbNQtAGzO17bRHux34sxqw2bdDhbUu5RJZaziKRqNj9bL6VxS/q JE8f4LgTrfwzlg4WqGVrtasBME9YyoyYToAnQVpnulasmSGwFh4ey6vXw2H1t0Nv4Cq48kAiZnSrR UZnBtGy75jlVH622X/5L+Q41Hqn/QF9bjpdqPEaUSp9aIxV8y5MjqH5LkiALMMY1Cpn5wKj2eGY+o L4yyKKTg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q9Adr-004Ik4-2D; Tue, 13 Jun 2023 20:29:27 +0000 Date: Tue, 13 Jun 2023 21:29:27 +0100 From: Matthew Wilcox To: "Vishal Moola (Oracle)" Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] mm/gup.c: Reorganize try_get_folio() Message-ID: References: <20230613201827.9441-1-vishal.moola@gmail.com> <20230613201827.9441-5-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613201827.9441-5-vishal.moola@gmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, Jun 13, 2023 at 01:18:26PM -0700, Vishal Moola (Oracle) wrote: > struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags) > { > + struct folio *folio; checkpatch will whinge about there not being a blank line here, and in this case, I think it's correct. > if (unlikely(!(flags & FOLL_PCI_P2PDMA) && is_pci_p2pdma_page(page))) > return NULL; > > + folio = try_get_folio(page, refs); > + > if (flags & FOLL_GET) > - return try_get_folio(page, refs); > - else if (flags & FOLL_PIN) { > - struct folio *folio; > + return folio; > > - /* > - * Can't do FOLL_LONGTERM + FOLL_PIN gup fast path if not in a > - * right zone, so fail and let the caller fall back to the slow > - * path. > - */ > - if (unlikely((flags & FOLL_LONGTERM) && > - !is_longterm_pinnable_page(page))) > - return NULL; > + if (unlikely(!(flags & FOLL_PIN))) { > + WARN_ON_ONCE(1); > + return NULL; Don't we need to folio_put_refs() in this case? Or rather, I think the if (WARN_ON_ONCE(flags & (FOLL_PIN|FOLL_GET) == 0) { test should be first. > + /* > + * CAUTION: Don't use compound_head() on the page before this > + * point, the result won't be stable. > + */ I think we can lose the comment at this point? > + if (!folio) > + return NULL;