Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4915450rdb; Fri, 15 Sep 2023 17:06:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQDDfhiphhemcxOewYDb5uYNTOQnYp7DRIRuFiJ6FdLDfNA/hNAb07WbCMrlwVtLziXcFn X-Received: by 2002:a17:902:eaca:b0:1bd:f71c:3af3 with SMTP id p10-20020a170902eaca00b001bdf71c3af3mr3041403pld.32.1694822818388; Fri, 15 Sep 2023 17:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694822818; cv=none; d=google.com; s=arc-20160816; b=O1E10VSObCd2v21Z50y9Dn3cHG2rpk3geCevcSqCVdbx3KADObZA10UTU7Abhq5m4a IB10z5GBB8p+iTI2CKfz58cW363c7syTbr1XFIzAidC4d4YlXB1FITZ4KsqSjD1TZMfG aMeRgtELPEcqqvcTgxu1aqLNDbD8HtrKUYf5a1qmGI8a8YD9MpxwVc2wviAR2BUgABht U/9jG4iXkBiyRlXN/Xc9HQXhRMbt6/L+clpBx7I5ltTj7DkXRCcfCeeIzPXY86ouptaO ztHEmrrCTYw3/z/Uz+QFGu/0b+WIY2M3jjN10v6usFUMVEq4Al/Spu2uunap/a6YFRZN olCw== 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=jxXdIOJ+m4CtsjucCCh39wV02TblO2va85pXUJ/Yaxs=; fh=ardmABoZqyzAm25ow9fvqe18o8v8L1P0+Wo2I9sPHpg=; b=aeH5vGsD2Rx4DaekUd4J/qLMnzTqBn+o96BRAgFCQuTCremIdiqFVknDAPIbHkvmCA 4hKpazxUHIVsoVJ313QsRsOp+I4k6/bqEAPF+BY2R9fD877AUC/C7Z15g+NILf8T/p6v 2T7yYtYO3dHqFpvivbL2+VZJmMWphnMdQhFjTZnKWWYvz4d0S0h8kNJX7O7dK21QLZnz GDqHKmbSK0QjaQHWb22sWi1ruNHN+DAUEElVlpkSebXt1/LqOilHPgN8ut1XqWVvvnDh FE48ND1PcYHqx9YM//cqsQlUoB+J4OXarNARSKAMPaLCaS47Vzsy6ly/6Dz5ZGIKlC2O naYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CTCz3ai5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id r12-20020a170902c60c00b001c08c0baedcsi3899473plr.67.2023.09.15.17.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CTCz3ai5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 825FF806A877; Fri, 15 Sep 2023 06:45:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235451AbjIONpM (ORCPT + 99 others); Fri, 15 Sep 2023 09:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235355AbjIONpL (ORCPT ); Fri, 15 Sep 2023 09:45:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FFD10D; Fri, 15 Sep 2023 06:45:06 -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=jxXdIOJ+m4CtsjucCCh39wV02TblO2va85pXUJ/Yaxs=; b=CTCz3ai5firDQReWo5r4TuUiQ5 kXQQkghy72n5L1ex9TNzv7XVPoz7XD1X/f4lUJw6/m0VHAYNSn4JFAZdNIg63Iw0KrL7KWX3vcgAx 336pifuSjH+xM+zHDElonJnmXzzpuBlrs5mnC8uUqMiByFLIra2P6PhSwdcj8kw9DqYFwT2mWN60c rjdTqjQdO3DCAiPOHCcaZ+264z9lBI1+gwt6DAWEvcjr6IY9u/XyP7zThcu4f35rOUVTHaONEnXzL vqVWgPjQFWsYclK8Ujfwc0jZPFSB/w80mArxsYa6YL6oS1PNSCORzHNNh5lBGLJ5Z/5BF0wT72g/T Jr9A9NWQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qh97y-00A1dO-Lq; Fri, 15 Sep 2023 13:44:58 +0000 Date: Fri, 15 Sep 2023 14:44:58 +0100 From: Matthew Wilcox To: Daniel Gomez Cc: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "gost.dev@samsung.com" , Pankaj Raghav Subject: Re: [PATCH 3/6] shmem: account for large order folios Message-ID: References: <20230915095042.1320180-1-da.gomez@samsung.com> <20230915095042.1320180-4-da.gomez@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230915095042.1320180-4-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:45:24 -0700 (PDT) On Fri, Sep 15, 2023 at 09:51:26AM +0000, Daniel Gomez wrote: > + xas_for_each(&xas, folio, max) { > + if (xas_retry(&xas, folio)) > continue; > - if (xa_is_value(page)) > - swapped++; > + if (xa_is_value(folio)) > + swapped += (folio_nr_pages(folio)); Unnecessary parens. > @@ -1006,10 +1006,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > folio = fbatch.folios[i]; > > if (xa_is_value(folio)) { > + long swaps_freed; > if (unfalloc) > continue; > - nr_swaps_freed += !shmem_free_swap(mapping, > - indices[i], folio); > + swaps_freed = folio_nr_pages(folio); > + if (!shmem_free_swap(mapping, indices[i], folio)) > + nr_swaps_freed += swaps_freed; Broader change (indeed, in a separate patch), why not make shmem_free_swap() return the number of pages freed, rather than returning an errno? > @@ -1075,14 +1077,16 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > folio = fbatch.folios[i]; > > if (xa_is_value(folio)) { > + long swaps_freed; > if (unfalloc) > continue; > + swaps_freed = folio_nr_pages(folio); > if (shmem_free_swap(mapping, indices[i], folio)) { > /* Swap was replaced by page: retry */ > index = indices[i]; > break; > } > - nr_swaps_freed++; > + nr_swaps_freed += swaps_freed; > continue; ... seems like both callers would prefer that.