From patchwork Tue Sep 19 13:55:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 142055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3607372vqi; Tue, 19 Sep 2023 11:51:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUljsHD9AptUDm/107kgvAuyiNFdzd00WT+trhHCuB8cdsPqYgAM+288yc9gtACw+4PqwR X-Received: by 2002:a17:903:2346:b0:1c4:56c8:27f8 with SMTP id c6-20020a170903234600b001c456c827f8mr186041plh.68.1695149464753; Tue, 19 Sep 2023 11:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695149464; cv=none; d=google.com; s=arc-20160816; b=Zjk9Dp+orb7wmzxVq8x1q6e7jN7f8FMiIeU+UjeU0FJ4Fw3UJ9c2C0D6V96SgTk9bi Syfa8dhcv0UmlowoRRq0V1pMa2sHaFWIf1QffwYlo3x34toMMY5rscNzP4X+0/HXQ4GK lb0GHYtd5+Dr1yTuEZypvuPEpCZoSrLrTXqOTR0oBJ71GsI68m93csEeqXEvxdtmK8mP 7qAbwEtalYhEIeT98dvdCWq1AZHerGM6IvuisGAsOG+BKMBnTbEkW3CaFgWREr+tsXXZ FJpMphYtDj7fNssz/6gJY0FxtzqqCz0JNyUMxipTkx700RaTJ+8rfB7W5Go2NrGENp+B PtXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=FJQ8bvj/9Vs0utzuzFMcJ8GvK3wVEgVmfOOT/zQHcR0=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=JHhnreuZh/+xD3LG7LkswLLiQjV/5U/kdlvUD1GAjvdmJ9Z7tNbcV1vWBwXtJHTBpA 1MgVflRwxY/wlinv5xd3wxbHpkHaOi3qj+/vmbd6XOfTGlM2KnumN8Wrues4muQq4pZJ R4OyY1orCq92uBsesK/CPvVmOPV9a3vU2E+HapOemC8xeVQ6Zzv2jvKIQ8RLP4Mj39Us rnmSuo9WoAonIN1+gS25TWItFAE0LFfAFrf3AWOMYZDEERP9nPjm/ye6y8YXY2k+Hc58 5Bp6otL8CGrcV3ZesSK71WrpvA6NhFSCtuP5FxZX4QQa65NOxDVZq4KBz+wlJV8k4XQG uaxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=l9ajOekS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y18-20020a170903011200b001c3a05b0b67si2699196plc.566.2023.09.19.11.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:51:04 -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=@samsung.com header.s=mail20170921 header.b=l9ajOekS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0603E80BB994; Tue, 19 Sep 2023 06:56:14 -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 S232558AbjISN4J (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbjISNz7 (ORCPT ); Tue, 19 Sep 2023 09:55:59 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4033BF9 for ; Tue, 19 Sep 2023 06:55:49 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135547euoutp013dec0c1c5411c8e82e326d1c7a94699f~GUVf2bx2r3233132331euoutp01i for ; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135547euoutp013dec0c1c5411c8e82e326d1c7a94699f~GUVf2bx2r3233132331euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131748; bh=FJQ8bvj/9Vs0utzuzFMcJ8GvK3wVEgVmfOOT/zQHcR0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=l9ajOekSgv9RJzUXI0V8msKFF5QnkT/CJnUhsjgVD4NdUPFXlfLckYb/3xjPj1PMZ qDkcM4L8ZFiYKUzR1tsXO5xr2fKk9prRBIhzl2ifkSItG4oZc34Lv7GRHghtd+6W+W 3C31ybcUB+q8s1eGeGnseu+HDZ7Gakffjb4/dqH4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135547eucas1p2511a5d8752168f2baa949be8ea4c10a6~GUVfeg3WY1636016360eucas1p2j; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3F.7E.11320.368A9056; Tue, 19 Sep 2023 14:55:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1~GUVfBq4u22317523175eucas1p27; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135547eusmtrp11e24cd154302622eacc81ec4f96cfcad~GUVe-9IqC2584925849eusmtrp1G; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-b6-6509a863472c Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A5.C9.10549.268A9056; Tue, 19 Sep 2023 14:55:46 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135546eusmtip1c60ef7b891afff594b8a2c51fcc57d87~GUVewBDRA1313713137eusmtip18; Tue, 19 Sep 2023 13:55:46 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:46 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:46 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Topic: [PATCH v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Index: AQHZ6wD8QPBGKC1ahkW+sk1T2Ar7wQ== Date: Tue, 19 Sep 2023 13:55:45 +0000 Message-ID: <20230919135536.2165715-2-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFKsWRmVeSWpSXmKPExsWy7djPc7rJKzhTDY73y1rMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MrZM2MBe8ZK2YvrmRpYHxOUsXIyeHhICJxJW+r2xdjFwcQgIrGCWOrDnMCuF8YZS4 tXQlI4TzmVFic+Nx5i5GDrCWiW+YIOLLGSV6jjcwgowCK9p0SgkicYZR4triA1DdKxklXlze zgxSxSagKbHv5CZ2kISIwGxWicOLO8DamQXqJNY8mwV2lbCApcTnzW/BbBEBO4k3d9YwQth6 Env23wezWQRUJY6f+cQEYvMKWEs83PIArJ5TwEbixtwmNhCbUUBW4tHKX+wQ88Ulbj2ZzwTx taDEotl7mCFsMYl/ux6yQdg6EmevP2GEsA0kti7dBw0lJYk/HQuh7tSTuDF1ChuErS2xbOFr ZogbBCVOznzCAvKYhEATl8T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LP/vtgNouAqsTxM5/AhvIKWEs83PIArF4IyH61cDXY fZwCNhI35jaB3c0oICvxaOUvdohd4hK3nsxngvhBQGLJnvPMELaoxMvH/6B+05E4e/0JI4Rt ILF16T4WCFtJ4k/HQqib9SRuTJ3CBmFrSyxb+JoZ4h5BiZMzn7BMYJSehWTdLCQts5C0zELS soCRZRWjSGppcW56brGhXnFibnFpXrpecn7uJkZggtp27OfmHYzzXn3UO8TIxMF4iFGCg1lJ hHemIVuqEG9KYmVValF+fFFpTmrxIUZTYBhNZJYSTc4Hpsi8knhDMwNTQxMzSwNTSzNjJXFe z4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamkNvNi/evPzFhr84ORrf1G8RahI1/PjyRul/T8cqi z+uuitZX8sQHtOwKr0q7lPyhQL2BPbcx/luZo8LJYiUpn42TubfySTXnFgn2fzh3Po/b787E mthXT3j2Cnc83vZo8VSv1hPl77jYJ/Hnv4prmbR26RyN+Ip67hC+8JfnSv9k+JRP6D5x2GGD p+jmn8/Tkj7N1VCeW2urzGo2oe1G54rlFXed2+a2CvnLKlpW31Xjv+Zs+t3dv+Wl/M6wNSur njnOzw1fPu8bi9TXZLv/SbLHPxe9fxPuL8mz7pNUlkZCqFR5krL2/6uuKwxSNdLmnojPNz+s n80imsDqYvtcTVWw6t7Owi2NJ++sUlBiKc5INNRiLipOBACISM272QMAAA== X-CMS-MailID: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 X-Msg-Generator: CA X-RootMTR: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 References: <20230919135536.2165715-1-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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]); Tue, 19 Sep 2023 06:56:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777493045357122854 X-GMAIL-MSGID: 1777493045357122854 The commit [1] replaced all BLOCKS_PER_PAGE in favor of the generic PAGE_SECTORS but definition was not removed. Drop it as unused macro. [1] e09764cff44b5 ("shmem: quota support"). Signed-off-by: Daniel Gomez Reviewed-by: Luis Chamberlain --- mm/shmem.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index be050efe18cb..de0d0fa0349e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -84,7 +84,6 @@ static struct vfsmount *shm_mnt; #include "internal.h" -#define BLOCKS_PER_PAGE (PAGE_SIZE/512) #define VM_ACCT(size) (PAGE_ALIGN(size) >> PAGE_SHIFT) /* Pretend that each entry is of this size in directory's i_size */ From patchwork Tue Sep 19 13:55:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 141900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3413800vqi; Tue, 19 Sep 2023 07:06:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXvNBTP0t5HZa7rtqa1kbv65SJS0yTz2RL7bg+w+sBI24JlGN0TocW1kCgwFKgyZvsuLET X-Received: by 2002:a17:902:e80a:b0:1b3:d4d5:beb2 with SMTP id u10-20020a170902e80a00b001b3d4d5beb2mr14522525plg.9.1695132401753; Tue, 19 Sep 2023 07:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695132401; cv=none; d=google.com; s=arc-20160816; b=aYzuR1uQ9ycTMNOSLqk/LC/BVWG7zSk8uv4gXz5uSZbgV1d5gTanB530TjGu0UvpUS qzyczrImEqRy0GPLmllq9XOmPQ7WG4bIlFtwaY1d/8+POI1uOKy2NaykwCHGRyFMKsV2 TpmwNEPWvjlzQO/vGSXYhcjLxWabjgpYVZ2Y2jYhePDVPZZlnhL8UzYaP9Tv0OYls8Ar 4IZuVlf+SEkn4GW/rzG3IZw3IK00mevuuBA7I+rApBubJc8hd8WFnFl+aKHuBFb6HDFl hBSxWqyexVRk85L/m/j82LQp9c9TFSwlKFRg+VNqp7QWUz13jGtSfIzL9g5TeJLBP3vr AeAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=0nMJXNMEWM3r3NxfSrFUqKN3QpE0A/RnobkmmeVN4jJC505y9DrKzn1PW/izVVtxOu uOo2e6R8KCSLeppnWtCfzXaPJz3IB8eL3pclxeq/h4JhalcCYgDsZZR0B9fMZJZAzdgR 7/9tTuZ7dXXbn9jCiViCjZvQ+omf65PKZLDywIR0NfkzZvVFUKenIEC52UeZNXm4Mh/A 2Ghbqa3GjNS579OIb19gd6scS7SsLJsQit1VDnnSrUfE9Rq9LH5Bp8NkrGSED7aCNtBw AI40X/+CSOFFs965Lfwz826cGdiE5Yanx0Xo7xXs1japC2kZh6vtaF1rym5rr7Zee1jn qbCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="S/I8tzNo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id kq13-20020a170903284d00b001bf1973eafcsi9616956plb.571.2023.09.19.07.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="S/I8tzNo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 466B88073DC7; Tue, 19 Sep 2023 06:58:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232487AbjISN4X (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbjISN4P (ORCPT ); Tue, 19 Sep 2023 09:56:15 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4745512D for ; Tue, 19 Sep 2023 06:55:53 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135549euoutp015e5a146ef879536908da6a9aa9d30519~GUVhq9Q2M3233132331euoutp01k for ; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135549euoutp015e5a146ef879536908da6a9aa9d30519~GUVhq9Q2M3233132331euoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131749; bh=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=S/I8tzNocRjVASDHLDVbZG1o0m5ySXDg7TpgNah3igHxxkIwUNZaIoedmh5F0HTBW dQo39hU3zNUXeSOhpV4FI2QiTwztjIioq1rd7Fsu8ItAWEjIVj4OLU9qcBike/4XPs KUXaM379aAsK8wBVtRcwGb7tZ3MbF+HOcWNmVaPI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eucas1p214bb8ae09e148c563a02f19655c58a3a~GUVhZ4Z1R1835818358eucas1p2Q; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C6.D1.42423.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf~GUVg-ov7A0405704057eucas1p1k; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eusmtrp2a092f04f72f32deca907d314cdbdbe2a~GUVg_3kxB2320823208eusmtrp2r; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-68-6509a8655322 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 00.55.14344.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135548eusmtip10e8f5eaa57c7ececc0fd70ba9f61c00f~GUVgvl2li1382813828eusmtip1a; Tue, 19 Sep 2023 13:55:48 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:48 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:48 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Topic: [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Index: AQHZ6wD9pblMkq2/yUu1kd4yGg7G6w== Date: Tue, 19 Sep 2023 13:55:47 +0000 Message-ID: <20230919135536.2165715-3-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110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kpB2 WPX++bgJz8wK/vYVJ9WLak8/tsHjieDTHatTV2vnGP5fau71YHZK0OkVWR1Xr1+XsI++adX0 lXdHQPWBxR+/GK0OUpfRaz9r77hZ4VpGU1RgrdmjL6EcS9MPHH4mfuj9o5hmhZtPA7fu9W/w /vOtVff2/b0X3rh94TL9YGtbuXjfvX8NG+SNa/6F6v9/2dwiv8A5fXbVnpcHvv+fXcFeVH+o QHBRflZMl3bQ7HVaBfr+KyxMlFiKMxINtZiLihMBgbk09dkDAAA= X-CMS-MailID: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf X-Msg-Generator: CA X-RootMTR: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf References: <20230919135536.2165715-1-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:58:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777475153546484183 X-GMAIL-MSGID: 1777475153546484183 Both shmem_free_swap callers require to get the number of pages in the folio after calling shmem_free_swap. Make shmem_free_swap return the expected value directly and return 0 number of pages being freed to avoid error handling in the external accounting. Suggested-by: Matthew Wilcox Signed-off-by: Daniel Gomez --- mm/shmem.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index de0d0fa0349e..5c9e80207cbf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -846,16 +846,18 @@ static void shmem_delete_from_page_cache(struct folio *folio, void *radswap) /* * Remove swap entry from page cache, free the swap and its page cache. */ -static int shmem_free_swap(struct address_space *mapping, +static long shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap) { void *old; old = xa_cmpxchg_irq(&mapping->i_pages, index, radswap, NULL, 0); if (old != radswap) - return -ENOENT; + return 0; + free_swap_and_cache(radix_to_swp_entry(radswap)); - return 0; + + return folio_nr_pages((struct folio *)radswap); } /* @@ -1008,7 +1010,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - nr_swaps_freed += !shmem_free_swap(mapping, + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); continue; } @@ -1077,12 +1079,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - if (shmem_free_swap(mapping, indices[i], folio)) { + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); + if (!nr_swaps_freed) { /* Swap was replaced by page: retry */ index = indices[i]; break; } - nr_swaps_freed++; continue; } From patchwork Tue Sep 19 13:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 142064 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3619359vqi; Tue, 19 Sep 2023 12:10:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqNdXq5LD4v9QPNLe51tOE+orwp3CQs/tXqNDHkoNd6JI3MXpYIoN7RBuaPxhhZCREUKYm X-Received: by 2002:a05:6a00:2d16:b0:68c:44ed:fb6 with SMTP id fa22-20020a056a002d1600b0068c44ed0fb6mr621796pfb.16.1695150627046; Tue, 19 Sep 2023 12:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695150627; cv=none; d=google.com; s=arc-20160816; b=fpIkb2tyct3NM5mg8WWmhMUGT64g9QyTAYtEebSE9qncOw2DUVSwJMuRDPCedaMjqv EAp7VTdhGbeTvi0nMgkfQ2782GA2BYp+xElzu5ny2/V372jiXUD1V4iDRVXFrV2g0C8w SJj5/DKXS1gio+vtUdfO0dnAkGcqdA/QN4n4MRafDLkCsWgUX3UTzwsN3x2N9YWa3bR3 fXIL1VkisEgC3F2vUjPaRP1aYGVil+SioDAMP1wrRQ+qidLXb0y9ekPxfxt1Y5SoA2JI LCw/A/bXtdlKyxjKrcRgGXj4HWDe9W+snN5Oi2j1mK8i9+UBQ15oQFUifW8+NvWOg4oX KWWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=M2nMBiTZd5j1892QPYWO6TsmBB5jyshwAT0VCE8LY5iwUP2/EW0HHVOxud0F3S/PZL 0pZWVC2VeDjQs3PzH2X3VylnHortWg2EsnMIACoJmoFvQSMQoBZUpvbHmm7U7A7baZ9i b4izlGq0WucL5h3Bx9Zimo2YAXYbXlRdpO+dL6uy6F8WpGdPzVzx6lUNZzNFqp68ZqTz DiU+JhBYtqxmTKWA/JqguItudP3VeoE5UzkvfmxivUHdhZk3P2+0qePpQubbdV6cx2Kq 23FAjxN5XUdKEeu0OwGJLQl7R9gSeJEDcf70mPxhEx8R+i3B7xhewUtPdA6N+YQkkoua p2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tyM4uvQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ay7-20020a056a00300700b0068fdb00659bsi10255308pfb.366.2023.09.19.12.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 12:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tyM4uvQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8579980BCB9F; Tue, 19 Sep 2023 06:58:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbjISN4U (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232564AbjISN4P (ORCPT ); Tue, 19 Sep 2023 09:56:15 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A01E128 for ; Tue, 19 Sep 2023 06:55:52 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135551euoutp02f32555391bed790dd27f9bf2a816b0fb~GUVjcKe_x1585015850euoutp02Y for ; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135551euoutp02f32555391bed790dd27f9bf2a816b0fb~GUVjcKe_x1585015850euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131751; bh=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tyM4uvQdUR1AS3aYkBsxN32j/P4q2FARUnPi8UjEsUaK/RInj4GTTsgiqt3Abi0EZ xPp6E2q79rArO2yh4Pg1Npb2OgCS+RY3naCuqZ/ExDsJ2hMNQOmyGDyPb3/9yCnggt 2eHzkHBjYlJcVe2tWGleBwTU4JIrtv0QzsVvrREg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230919135551eucas1p1c2f79426cc02c6873649747c6b5ebe77~GUVjFDdBx1658916589eucas1p1F; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 23.8E.11320.768A9056; Tue, 19 Sep 2023 14:55:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db~GUVilHeug1635116351eucas1p2u; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135550eusmtrp2e393e76eb8216b24e9888cc400ce0942~GUVikiwv92324623246eusmtrp2F; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-c7-6509a8674f70 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 32.55.14344.668A9056; Tue, 19 Sep 2023 14:55:50 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eusmtip17b6283cd8a9ef8f53119b7dcf49ffc0f~GUViY2AR61888818888eusmtip1z; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:50 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:50 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 3/6] shmem: account for large order folios Thread-Topic: [PATCH v2 3/6] shmem: account for large order folios Thread-Index: AQHZ6wD+Wqd1jPdfPEKUQlAv9fdGJA== Date: Tue, 19 Sep 2023 13:55:49 +0000 Message-ID: <20230919135536.2165715-4-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 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V6V9b/bj/y2sZ5Bc82zY2p z1lvLBR4u+BrxvMnrA1Xmh46vFSeyvtqrf2NwDrdj+qHzRbdLedcuyVTvJDlt3KleeHRw2r/ 7P5lGS774MfGtjo8XbQshue7561TZ1ZxZKUc9pqWxT7Td8Epg2d8pyZrROQHW6d//CQjeG71 V+Yzt88wpfxYGPusTSU1/KAst5ldK19A1Mygz7mf5XO9CpW4Zj4QPH/F49XJZqG4u/ZXj8he uXbrg+n9Z4xrLzXkuS7f68zpd6lVIn65EktxRqKhFnNRcSIAM2aVQtcDAAA= X-CMS-MailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-Msg-Generator: CA X-RootMTR: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db References: <20230919135536.2165715-1-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:58:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777494263952570371 X-GMAIL-MSGID: 1777494263952570371 From: Luis Chamberlain shmem uses the shem_info_inode alloced, swapped to account for allocated pages and swapped pages. In preparation for large order folios adjust the accounting to use folio_nr_pages(). This should produce no functional changes yet as larger order folios are not yet used or supported in shmem. Signed-off-by: Luis Chamberlain Signed-off-by: Daniel Gomez --- mm/shmem.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5c9e80207cbf..d41ee5983fd4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -871,16 +871,16 @@ unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end) { XA_STATE(xas, &mapping->i_pages, start); - struct page *page; + struct folio *folio; unsigned long swapped = 0; unsigned long max = end - 1; rcu_read_lock(); - xas_for_each(&xas, page, max) { - if (xas_retry(&xas, page)) + 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); if (xas.xa_index == max) break; if (need_resched()) { @@ -1530,7 +1530,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) if (add_to_swap_cache(folio, swap, __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN, NULL) == 0) { - shmem_recalc_inode(inode, 0, 1); + shmem_recalc_inode(inode, 0, folio_nr_pages(folio)); swap_shmem_alloc(swap); shmem_delete_from_page_cache(folio, swp_to_radix_entry(swap)); @@ -1803,6 +1803,7 @@ static void shmem_set_folio_swapin_error(struct inode *inode, pgoff_t index, struct address_space *mapping = inode->i_mapping; swp_entry_t swapin_error; void *old; + long num_swap_pages; swapin_error = make_poisoned_swp_entry(); old = xa_cmpxchg_irq(&mapping->i_pages, index, @@ -1812,13 +1813,14 @@ static void shmem_set_folio_swapin_error(struct inode *inode, pgoff_t index, return; folio_wait_writeback(folio); + num_swap_pages = folio_nr_pages(folio); delete_from_swap_cache(folio); /* * Don't treat swapin error folio as alloced. Otherwise inode->i_blocks * won't be 0 when inode is released and thus trigger WARN_ON(i_blocks) * in shmem_evict_inode(). */ - shmem_recalc_inode(inode, -1, -1); + shmem_recalc_inode(inode, -num_swap_pages, -num_swap_pages); swap_free(swap); } @@ -1905,7 +1907,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, if (error) goto failed; - shmem_recalc_inode(inode, 0, -1); + shmem_recalc_inode(inode, 0, -folio_nr_pages(folio)); if (sgp == SGP_WRITE) folio_mark_accessed(folio); @@ -2665,7 +2667,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (ret) goto out_delete_from_cache; - shmem_recalc_inode(inode, 1, 0); + shmem_recalc_inode(inode, folio_nr_pages(folio), 0); folio_unlock(folio); return 0; out_delete_from_cache: From patchwork Tue Sep 19 13:55:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 141958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3469636vqi; Tue, 19 Sep 2023 08:21:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNRxAas9lsD+bKekKtXPnpiAbqwRGJfPcslupYSs4RHPz8Mn83SjXe9BAewOqFseBsUtF0 X-Received: by 2002:a17:903:22c6:b0:1c3:2423:8e24 with SMTP id y6-20020a17090322c600b001c324238e24mr12652885plg.8.1695136862146; Tue, 19 Sep 2023 08:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695136861; cv=none; d=google.com; s=arc-20160816; b=WeMFmRzgYTp22p88FXHw5PYwpqzvcALjO/bllCZkmodxOMBMEKBQqscO7fNGzsmbCw nUy9RJmc5yHxBFfsyz/NaFEH7howbFCFS8s7K0oC3v05SBsA6yEsYonY4oXVzykS+gQa svWWFFqeU24D7uKXO+BMOYRup7xdParP03JPcj9+z5QTPnFFzA8jkKnNUnro9XEIjcJa p/KmLdqXC5N61guW6IHHsdNwuaKrKWJvcp44c9UeShlD895Jsklgo5ReRu5rXz9IbNNW stbVKB8GrfE79zNIqxoyIWivcWBJDg39ocdU9b35Xz1OeNN7HLRvUhcccj70dXw8qaCm EUYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=j5/WuYRozdtOAgqCuDPHuq7YO9f8GU76Eza03ZT/hH0=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=xK9liQN1davcIKzuk0bWcvix67hbE7kf6rCM5fYsCiO5+DsHAQHNWSFcbZm9Kssj5S ostZn+I1Ed1FCQlQlKE147ymKLJnY3LFwvEA0bZM4TxPnbW8+tUihPwH25wPVVHPnEE2 cqs1KJ/Lcsj2zEV1MEOAJ9G72/G5Ya/pzxlD/Amg4/QJtnHWaryQRYWy3IdTcLMKftSr RWPKfM1w3br1Z9m9McVKt5WGOjibRBtodBgNLJrJBuWD+fm076qbf15aYs/WYNNGNJTM Pzs54cTvgjAVBFp8LWBLvEVrGAnwbNYVdLazuXCB3tw8fhQOX2yYKK0SnkJ1gPpwA8Nu L+RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Nuk+vBjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y10-20020a170902864a00b001bc836180dcsi9733232plt.520.2023.09.19.08.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 08:21:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Nuk+vBjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8AA578260FBE; Tue, 19 Sep 2023 06:57:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232658AbjISN4e (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232504AbjISN4Q (ORCPT ); Tue, 19 Sep 2023 09:56:16 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB3C0186 for ; Tue, 19 Sep 2023 06:55:54 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135553euoutp02ee620fb8c3498468273d05023a349416~GUVkz2XGG1585015850euoutp02b for ; Tue, 19 Sep 2023 13:55:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135553euoutp02ee620fb8c3498468273d05023a349416~GUVkz2XGG1585015850euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131753; bh=j5/WuYRozdtOAgqCuDPHuq7YO9f8GU76Eza03ZT/hH0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Nuk+vBjmOh37sbt6+cadKZVS5pDdzpixYn6VfaHIUcxAPCiEoA5HyMHU16U4AXzlS uAY13cUs5iF3t9vzP0Wwptp6v7rcHcS1QS4p2z9CuSenJGbi8FP5xvy52tPDOa5C+A HquMNJPl6Mp5dXIMgriwdNYppSWors5aDVdkPq2A= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135552eucas1p24dc412b1eadbba23c9d14f70df03b1ac~GUVkXHo8C1636016360eucas1p2s; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C5.8E.11320.868A9056; Tue, 19 Sep 2023 14:55:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9~GUVj9gkvl1092210922eucas1p1Q; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135552eusmtrp1594d9a0d3fd5111d702d62a93bc6f02d~GUVj8zkSl2614026140eusmtrp1G; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-ca-6509a868e751 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9C.C9.10549.868A9056; Tue, 19 Sep 2023 14:55:52 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135552eusmtip105fc41d27402e30d4f75b71c970cf4f9~GUVjooqQg1607416074eusmtip1K; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:51 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:51 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Topic: [PATCH v2 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Index: AQHZ6wD/X9RVQ39BEEGXAtoeSmDJSA== Date: Tue, 19 Sep 2023 13:55:50 +0000 Message-ID: <20230919135536.2165715-5-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOKsWRmVeSWpSXmKPExsWy7djPc7oZKzhTDSZu1rWYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZW/ecYyrolamYv6GJqYHxgVgXIweHhICJxJ8LHl2MXBxCAisYJe6tuMMM4XxhlPh1 YDUThPOZUWLD3ZVADidYx/w5KxkhEssZJb6tWc8MkgCrevA0HCJxhlFi4qyl7BCJlYwSS1dy g9hsApoS+05uYgcpEhGYzSpxeHEHI0iCWaBOYs2zWSwgtrBAoMTFphVsILaI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NDQsBEYv6clYxdjFwcQgJLGSXerDzHBpGQkdj45SorhC0s8edaFxtE0UdGicOr 25ghnDOMEh9fPWSCcFYySjxfcQCshU1AU2LfyU3sIAkRgdmsEocXdzCCJJgF6iTWPJvFAmIL CwRKXGxaAbZPRCBM4svthUA2B5CtJ7GlNwIkzCKgKtG46SpYOa+AtcShwy/AbCEg+9XC1WC7 OAVsJG7MbQIbwyggK/Fo5S92iFXiEreezGeCeEFAYsme88wQtqjEy8f/oF7TkTh7/QkjhG0g sXXpPhYIW0niT8dCqJP1JG5MncIGYWtLLFv4mhniHkGJkzOfsExglJ6FZN0sJC2zkLTMQtKy gJFlFaNIamlxbnpusaFecWJucWleul5yfu4mRmCC2nbs5+YdjPNefdQ7xMjEwXiIUYKDWUmE d6YhW6oQb0piZVVqUX58UWlOavEhRlNgGE1klhJNzgemyLySeEMzA1NDEzNLA1NLM2MlcV7P go5EIYH0xJLU7NTUgtQimD4mDk6pBiYFLuOZt28WrO5KuKGw/6/E0/2FPu8/fnG65j+v43WC as2EAyEhqoLV4cdK7upo1S27tYWV71PQ/Uv/vL88n/df7udXwe+FH98ptN1Mqk67694b/utD v1NQxtPi/+ZiTzW7BN0n9e4S1srJ+J/fdHra3o5faqFXXPWuhBq8DjzkGjz/hTlP66ND7LNr 849s5VD1uvlI2UlaqtDLjW95guW039IqP08cUJniq6I2Q3qZ4ifF2ztfiRmeq2G8Wa9ncevQ io539UsecJz/cXGacN7nFwe+l5620vh6pMmw1pn19J2tS/OTP5dXTo9vv/Pj2zHL/jfztEKC pTOr/XjCIhRMHzHeWNQ2+cEUSY7oXY+UWIozEg21mIuKEwFsJZsF2QMAAA== X-CMS-MailID: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 X-Msg-Generator: CA X-RootMTR: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 References: <20230919135536.2165715-1-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:57:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777479830067698481 X-GMAIL-MSGID: 1777479830067698481 In preparation for high order folio support for the write path, add order parameter when allocating a folio. This is on the write path when huge support is not enabled or when it is but the huge page allocation fails, the fallback will take advantage of this too. Use order 0 for the non write paths such as reads or swap in as these currently lack high order folios support. Signed-off-by: Daniel Gomez --- mm/shmem.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index d41ee5983fd4..66d94207b40c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1667,20 +1667,21 @@ static struct folio *shmem_alloc_hugefolio(gfp_t gfp, } static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) + struct shmem_inode_info *info, pgoff_t index, + unsigned int order) { struct vm_area_struct pvma; struct folio *folio; shmem_pseudo_vma_init(&pvma, info, index); - folio = vma_alloc_folio(gfp, 0, &pvma, 0, false); + folio = vma_alloc_folio(gfp, order, &pvma, 0, false); shmem_pseudo_vma_destroy(&pvma); return folio; } static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, - pgoff_t index, bool huge) + pgoff_t index, bool huge, unsigned int *order) { struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; @@ -1689,7 +1690,7 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) huge = false; - nr = huge ? HPAGE_PMD_NR : 1; + nr = huge ? HPAGE_PMD_NR : 1U << *order; err = shmem_inode_acct_block(inode, nr); if (err) @@ -1698,7 +1699,7 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, if (huge) folio = shmem_alloc_hugefolio(gfp, info, index); else - folio = shmem_alloc_folio(gfp, info, index); + folio = shmem_alloc_folio(gfp, info, index, *order); if (folio) { __folio_set_locked(folio); __folio_set_swapbacked(folio); @@ -1748,7 +1749,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, */ gfp &= ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new = shmem_alloc_folio(gfp, info, index); + new = shmem_alloc_folio(gfp, info, index, 0); if (!new) return -ENOMEM; @@ -1959,6 +1960,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, int error; int once = 0; int alloced = 0; + unsigned int order = 0; if (index > (MAX_LFS_FILESIZE >> PAGE_SHIFT)) return -EFBIG; @@ -2034,10 +2036,12 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, huge_gfp = vma_thp_gfp_mask(vma); huge_gfp = limit_gfp_mask(huge_gfp, gfp); - folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true); + folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true, + &order); if (IS_ERR(folio)) { alloc_nohuge: - folio = shmem_alloc_and_acct_folio(gfp, inode, index, false); + folio = shmem_alloc_and_acct_folio(gfp, inode, index, false, + &order); } if (IS_ERR(folio)) { int retry = 5; @@ -2600,7 +2604,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (!*foliop) { ret = -ENOMEM; - folio = shmem_alloc_folio(gfp, info, pgoff); + folio = shmem_alloc_folio(gfp, info, pgoff, 0); if (!folio) goto out_unacct_blocks; From patchwork Tue Sep 19 13:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 142030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3569504vqi; Tue, 19 Sep 2023 10:46:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXwnL+GRX2YVoUyXgn4+z2JTSp1lc+JO5Mx48KocmCYwZhJ0xAMqoUhKO5I2d5nMJXnrxk X-Received: by 2002:a05:6a20:5603:b0:14c:5c5d:ba93 with SMTP id ir3-20020a056a20560300b0014c5c5dba93mr203939pzc.56.1695145575040; Tue, 19 Sep 2023 10:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695145575; cv=none; d=google.com; s=arc-20160816; b=raO7ic3MgrrO5pgO3L+CoFbsAS6LRzOw80bp4EwM5O1R0iMPUxf6KaF4bXskkiR5+M qgZQxGg7N7M/wXY3XEfpb/5rh0GkNUX1rc0BZVQX+4GRDaTHalyr1NphJlOrG2ugQApk vFuF7ZvHC636pcKaZ2H3T6jeiUGXItIRKdMM9ncUgYrtAUqrGh1Ar1Ak9XpQSGj7md2+ 9kreq7KbRhwcDhOJ8+ifb4nHh0dIGIHmBTh044n9A65xbg8x/4r3BwoZB9d3s7xB75ON puEK07IMqWmx12uEpQQx+xk/sj0EBxCbcodAPqDUFGkK4Jhrwf08tXhoCvQ3eT5uAfC+ A2Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=qf0ZYfltBJHFQkocAMfpwOGkTFM18/mnXm/sqbTG1Hc=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=0yMp/eVuJa7v3agAodTIrxcWCYLox2s6YNHN792QhavItxWdFPVV6STv20Jzgt20K4 bwh65R6WSU2JrpxQhoIhlOMCrhKXKigEQbqjv1BItYF3fyuWdJ5tRMa9RbsKRTCN1sFD KiJPsCTnq0IduoNGoyWjJOnYeHU4FIU2LckttVm6MBZ4hADNiOkAmKJJ7rZWuHLj27Xs It7VD0UPjJCyvIyGSs83J1nhFsQ+RWQy9cI+yA7jFOs015Frb+85o/u3SpEeC/bCA6Gy na729ZDgU+/UFHrLB3fKSacad7LRcWMTwieFdgX7y1P90lBE6EstlbgK2W7VTgGOidKC X9uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RdyrgSlx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u64-20020a638543000000b00578cc95d3fbsi494870pgd.635.2023.09.19.10.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 10:46:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RdyrgSlx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CB0A7819CC33; Tue, 19 Sep 2023 06:57:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232615AbjISN4n (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232514AbjISN4R (ORCPT ); Tue, 19 Sep 2023 09:56:17 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9657718E for ; Tue, 19 Sep 2023 06:55:56 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135554euoutp0235a576da43d96a93c2ac893998026581~GUVmPOGDV1585015850euoutp02c for ; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135554euoutp0235a576da43d96a93c2ac893998026581~GUVmPOGDV1585015850euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131754; bh=qf0ZYfltBJHFQkocAMfpwOGkTFM18/mnXm/sqbTG1Hc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=RdyrgSlxDQnZ8OoTspAB8yPA4ahyu5un4f+0ntoCmwiJDcdh42jompH23sIq8BVqW ed8f1O+Q8HVOUfEHREfoorxQqo4i608JK7GT+n2oHWziyh0TcWPrXrc2pUNg0wsJie 1zSJwpiEYbsFnS+ZEdeLgKqZPJ2kcKgs6RKMQ9GQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135554eucas1p2c289f7b4360774a8577116bad4b22a34~GUVmEZqWP1832118321eucas1p2Q; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 44.72.37758.A68A9056; Tue, 19 Sep 2023 14:55:54 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c~GUVli9uA70405804058eucas1p13; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135554eusmtrp145105151189bdca9c761ae4116051b63~GUVliU81s2584925849eusmtrp1S; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-ca-6509a86ab4f5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id EE.C9.10549.968A9056; Tue, 19 Sep 2023 14:55:54 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135553eusmtip1da98dd855cbc6c425b4b7b0a0fa939af~GUVlXP9Nk1382813828eusmtip1f; Tue, 19 Sep 2023 13:55:53 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:53 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:53 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 5/6] shmem: add file length in shmem_get_folio path Thread-Topic: [PATCH v2 5/6] shmem: add file length in shmem_get_folio path Thread-Index: AQHZ6wEANquhpkBXk0KILtjKWHTHrQ== Date: Tue, 19 Sep 2023 13:55:52 +0000 Message-ID: <20230919135536.2165715-6-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBKsWRmVeSWpSXmKPExsWy7djP87pZKzhTDV4vVbaYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZ7TdnsRdc1a14tUGjgXGHShcjJ4eEgIlEz4Yr7F2MXBxCAisYJWbPPcUC4XxhlPjy 4BszhPOZUaK36QYbTMvG1QsYIRLLGSU+vF/FBlf16WU/O0iVkMAZRolT7dEQiZWMEjOO9DOD JNgENCX2ndwEtlFEYDarxOHFHYwgCWaBOok1z2YBbefgEBZwk5h2phwkLCLgLdH85yIzSFhE QE+i/aYJSJhFQFXi28xbLCA2r4C1xIp3E8GmcArYSNyY2wR2KaOArMSjlb/YIaaLS9x6Mp8J 4gNBiUWz9zBD2GIS/3Y9hPpMR+Ls9SeMELaBxNal+1ggbCWJPx0Loa7Uk7gxdQobhK0tsWzh a2aIGwQlTs58Ag47CYE2LolXtw9BNbtIrL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IRZBFQlvs28xQJi8wpYS6x4NxFsihCQ/Wrh arDrOAVsJG7MbQJbyyggK/Fo5S92iE3iEreezIf6RkBiyZ7zzBC2qMTLx/+gPtOROHv9CSOE bSCxdek+FghbSeJPx0Koi/UkbkydwgZha0ssW/iaGeIeQYmTM5+wTGCUnoVk3SwkLbOQtMxC 0rKAkWUVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYHLaduzn5h2M81591DvEyMTBeIhRgoNZ SYR3piFbqhBvSmJlVWpRfnxRaU5q8SFGU2AYTWSWEk3OB6bHvJJ4QzMDU0MTM0sDU0szYyVx Xs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGpobjl9OXWAUyCq+pPcfb+bPlqcDuP+pPdd4c6hHq vj7txvJz795/tfncVTDtaKPU3Ne5Mxafme5pHeFT3/Bma/thc8fG8kP3by94GFlyYrnjj5cn xT7zRm64Jmfb/2H3FzujrheM604EdUs4H4+z+ffA9HgSb9z6qwv+/tv9TPvqkysTF/VfnaLQ rXnqn/rdmTVP2Z0j0g/t4+U0K13/udbY/fW8R/fWPdyyx0nbJlO+/TZblpr/jJSbQkmBKzdF MEcyx+au//hoX+tdrZk6vu8YHwh982NOleJ78qEyoz/LvSNFXspDZ3FCVO3PwqUxCcfXex5M T15oWOJy9JXOa18fmT2M5dJqW2TiHvd/+qHEUpyRaKjFXFScCAB3yF0I1wMAAA== X-CMS-MailID: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c X-Msg-Generator: CA X-RootMTR: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c References: <20230919135536.2165715-1-da.gomez@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:57:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777488966795834673 X-GMAIL-MSGID: 1777488966795834673 To be able to calculate folio order based on the file size when allocation occurs on the write path. Use of length 0 for non write paths and PAGE_SIZE for pagecache read and vm fault. Signed-off-by: Daniel Gomez --- include/linux/shmem_fs.h | 2 +- mm/khugepaged.c | 2 +- mm/shmem.c | 32 ++++++++++++++++++-------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 6b0c626620f5..b3509e7f1054 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -133,7 +133,7 @@ enum sgp_type { }; int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, - enum sgp_type sgp); + enum sgp_type sgp, size_t len); struct folio *shmem_read_folio_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 88433cc25d8a..e5d3feff6de6 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1856,7 +1856,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, xas_unlock_irq(&xas); /* swap in or instantiate fallocated page */ if (shmem_get_folio(mapping->host, index, - &folio, SGP_NOALLOC)) { + &folio, SGP_NOALLOC, 0)) { result = SCAN_FAIL; goto xa_unlocked; } diff --git a/mm/shmem.c b/mm/shmem.c index 66d94207b40c..38aafa0b0845 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -971,7 +971,7 @@ static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) * (although in some cases this is just a waste of time). */ folio = NULL; - shmem_get_folio(inode, index, &folio, SGP_READ); + shmem_get_folio(inode, index, &folio, SGP_READ, 0); return folio; } @@ -1948,7 +1948,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, - vm_fault_t *fault_type) + vm_fault_t *fault_type, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -2162,10 +2162,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, } int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, - enum sgp_type sgp) + enum sgp_type sgp, size_t len) { return shmem_get_folio_gfp(inode, index, foliop, sgp, - mapping_gfp_mask(inode->i_mapping), NULL, NULL, NULL); + mapping_gfp_mask(inode->i_mapping), + NULL, NULL, NULL, len); } /* @@ -2248,8 +2249,8 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf) spin_unlock(&inode->i_lock); } - err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, - gfp, vma, vmf, &ret); + err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, gfp, + vma, vmf, &ret, PAGE_SIZE); if (err) return vmf_error(err); if (folio) @@ -2700,6 +2701,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping, struct folio *folio; int ret = 0; + if (!mapping_large_folio_support(mapping)) + len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos)); + /* i_rwsem is held by caller */ if (unlikely(info->seals & (F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_FUTURE_WRITE))) { @@ -2709,7 +2713,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping, return -EPERM; } - ret = shmem_get_folio(inode, index, &folio, SGP_WRITE); + ret = shmem_get_folio(inode, index, &folio, SGP_WRITE, len); if (ret) return ret; @@ -2781,7 +2785,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - error = shmem_get_folio(inode, index, &folio, SGP_READ); + error = shmem_get_folio(inode, index, &folio, SGP_READ, 0); if (error) { if (error == -EINVAL) error = 0; @@ -2958,7 +2962,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, break; error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, - SGP_READ); + SGP_READ, 0); if (error) { if (error == -EINVAL) error = 0; @@ -3145,7 +3149,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, error = -ENOMEM; else error = shmem_get_folio(inode, index, &folio, - SGP_FALLOC); + SGP_FALLOC, 0); if (error) { info->fallocend = undo_fallocend; /* Remove the !uptodate folios we added */ @@ -3500,7 +3504,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_op = &shmem_short_symlink_operations; } else { inode_nohighmem(inode); - error = shmem_get_folio(inode, 0, &folio, SGP_WRITE); + error = shmem_get_folio(inode, 0, &folio, SGP_WRITE, 0); if (error) goto out_remove_offset; inode->i_mapping->a_ops = &shmem_aops; @@ -3548,7 +3552,7 @@ static const char *shmem_get_link(struct dentry *dentry, return ERR_PTR(-ECHILD); } } else { - error = shmem_get_folio(inode, 0, &folio, SGP_READ); + error = shmem_get_folio(inode, 0, &folio, SGP_READ, 0); if (error) return ERR_PTR(error); if (!folio) @@ -4916,8 +4920,8 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, int error; BUG_ON(!shmem_mapping(mapping)); - error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, - gfp, NULL, NULL, NULL); + error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, gfp, NULL, + NULL, NULL, PAGE_SIZE); if (error) return ERR_PTR(error); From patchwork Tue Sep 19 13:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 141938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3451665vqi; Tue, 19 Sep 2023 07:59:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvyCTxxbYf9hlEzcmGV/ozS8VJAnLM5GXtwbERhr8fxvWAjelXJTrsUKSyq6irlNxlpll6 X-Received: by 2002:a17:90a:ca09:b0:274:8ed5:6b4d with SMTP id x9-20020a17090aca0900b002748ed56b4dmr9290495pjt.11.1695135574062; Tue, 19 Sep 2023 07:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695135574; cv=none; d=google.com; s=arc-20160816; b=yZvj2VwN6s1CqSb/DSmsEjHEO96gJLDt1Hj6rL5FfeZvDx5AFOm/KxNhoHeiCifOsh EhdQjBvFdopG+VEWZhR8s0Gk4hkGlSYhdaMssoQ6KRn76znLJ9HKYeLvBVGLIhGqu7WC c2zxyYbW57jlDbj1M6Ynh/bwFzauZYz+CByrQmV3xSkcueDVlXjdWZ0+X862abiFw7kw ymvr8u0ZljJJgvGqIfbSdUDofIAz0bl3WydSzu5L0jQoIeEyEdosZ/LooEM66wtU1oDB rK9M4gXemjR23O1LZvJvZP6LO8+RfI/lKczB+q3f96hETsEzPFQTO5VyhSQ3WtlFOWH4 TLvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=JKaS2+/EEMvNdZiV+zve2PZ9hmK4b8LE7tpeT3AMyFo=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=sGv87dHL/ST6pdgKoJm2DC5MqF6YuGamflnHi/Fr3dW5kOnHjz5pXdEYQsRZ2s8H2n /ILhRYgfz8I9xIM1+ASsQLYuSMDGTK8KKa4VEiVXatrUjNVktTovcqZ476jKtJ4qzSPG 135GvbgiFxHcdCUGd7vg4mZsfjbDYQCjjJpX06NaFk6FNtQlmYMnW4J+qZ487bDEoAP3 fKVL+N/1BxKL9RuZrPWbwxTr65FKXTvpsWoTmLoo6PpL5dKkLz51HVFJLEeMV7DjfKmb xVhjmJsZpcaSDrVDW/1S5sRvgYIq1m5ZA7h0TOH1/YMb82e3NHl9jgwuw6MfvnyPuBRd 3wDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nuctfpPH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id mi15-20020a17090b4b4f00b00274b944508fsi6546894pjb.39.2023.09.19.07.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:59:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nuctfpPH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 56A4E8028871; Tue, 19 Sep 2023 06:56:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbjISN4j (ORCPT + 26 others); Tue, 19 Sep 2023 09:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232615AbjISN4b (ORCPT ); Tue, 19 Sep 2023 09:56:31 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AF01A3 for ; Tue, 19 Sep 2023 06:55:58 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135557euoutp02a0082ff79b2db0fa4562f008cbea92a9~GUVoYs05k1585715857euoutp02Q for ; Tue, 19 Sep 2023 13:55:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135557euoutp02a0082ff79b2db0fa4562f008cbea92a9~GUVoYs05k1585715857euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131757; bh=JKaS2+/EEMvNdZiV+zve2PZ9hmK4b8LE7tpeT3AMyFo=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=nuctfpPHnSMC7WQhH3HQtlmt0BgRwRmZt8mRpYkEnpagsqTg5Xc3QzV+nXnDwFb6D lxURGbKYETqe7oCM8Mgw+BtSPsANdW2I0sC1Kk9USuK7719XgBh986WUD/UyXmzVnP 2kwtvOkEHXQIb3zoZiL0vNOSS/gXZ178cpLtEY6M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135556eucas1p25528f9f56de359f45b1e7b88035e664a~GUVn702Uc1835018350eucas1p2T; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FE.D1.42423.C68A9056; Tue, 19 Sep 2023 14:55:56 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117~GUVnbnZpF0405804058eucas1p16; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135556eusmtrp27b41cacf6044fd9f4708968fe6ddd715~GUVna-NnB2324623246eusmtrp2O; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-8a-6509a86cdb59 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 38.55.14344.B68A9056; Tue, 19 Sep 2023 14:55:55 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135555eusmtip1dc621754b1f2f7018cbadae30e65482e~GUVnMaPw61888818888eusmtip14; Tue, 19 Sep 2023 13:55:55 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:55 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:55 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.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" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH v2 6/6] shmem: add large folios support to the write path Thread-Topic: [PATCH v2 6/6] shmem: add large folios support to the write path Thread-Index: AQHZ6wEBFE+DTgi9xUu5khR159FX3A== Date: Tue, 19 Sep 2023 13:55:54 +0000 Message-ID: <20230919135536.2165715-7-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNKsWRmVeSWpSXmKPExsWy7djP87o5KzhTDfZtVLSYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZk1c8Yyx4pVxx5/YElgbG2zJdjJwcEgImEk8ebmACsYUEVjBKtNzJ6GLkArK/MEr8 vbWdHcL5zChx5t17dpiOgye+MUEkljNKzLv4nAWuauGkL8wQzhlGic4X06GclYwS1xf9Aetn E9CU2HdyE9hgEYHZrBKHF3cwgiSYBeok1jybxQJiCwt4Sqw/ehWsQUQgQKKt/woThK0n8XfZ STCbRUBV4t2/hWC9vALWEj8nHgKLcwrYSNyY28QGYjMKyEo8WvmLHWK+uMStJ/OZIJ4QlFg0 ew8zhC0m8W/XQzYIW0fi7PUnjBC2gcTWpftYIGwliT8dC6Hu1JO4MXUKG4StLbFs4WtmiBsE JU7OfAIOCwmBf5wS02auhxrkItE79yHUMmGJV8e3QENSRuL/zvlMExi1ZyG5bxaSHbOQ7JiF ZMcCRpZVjOKppcW56anFhnmp5XrFibnFpXnpesn5uZsYgent9L/jn3Ywzn31Ue8QI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k/HQuhbtaTuDF1ChuErS2xbOFrZoh7BCVOznzCMoFRehaSdbOQtMxC0jILScsC RpZVjCKppcW56bnFRnrFibnFpXnpesn5uZsYgSlq27GfW3Ywrnz1Ue8QIxMH4yFGCQ5mJRHe mYZsqUK8KYmVValF+fFFpTmpxYcYTYFhNJFZSjQ5H5gk80riDc0MTA1NzCwNTC3NjJXEeT0L OhKFBNITS1KzU1MLUotg+pg4OKUamKY0sD3SbStZePl74E6P/u7P+56FFDDFCxd47pzP/ShM Z+nfY7pee44yWPTXM79S5dqiW/k/zsxoj45P6Nvlro1b6+R/bJghk/RNzEM29q31l5kc+X+U XZMn/mv72vVL6b2ziQKfqd9uXdHnexZ0GVcc36+56+l8lZ6D+ikM+5WDlPgWWL1alVV+mCPe 5YLJqw33uqyLNBS0vqxZ2aR0sJWz9f0XPU/H/fJCU/UXRPjWtVWF7Vi19c0nRg/9T6kZF38H G97/emt20tnNG+rNZt50C9rokSYts90pS0/c/k1mUL/OYbOVF7TnKPZt1fyVZj9vysTvWzIf XtxfUfbmaKl8c/Dygk2Gm/WyowyvKLEUZyQaajEXFScCAEql5LjaAwAA X-CMS-MailID: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 X-Msg-Generator: CA X-RootMTR: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 References: <20230919135536.2165715-1-da.gomez@samsung.com> 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_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:56:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777478480048730306 X-GMAIL-MSGID: 1777478480048730306 Add large folio support for shmem write path matching the same high order preference mechanism used for iomap buffered IO path as used in __filemap_get_folio() with a difference on the max order permitted (being PMD_ORDER-1) to respect the huge mount option when large folio is supported. Use the __folio_get_max_order to get a hint for the order of the folio based on file size which takes care of the mapping requirements. Swap does not support high order folios for now, so make it order 0 in case swap is enabled. Signed-off-by: Daniel Gomez --- mm/shmem.c | 66 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 38aafa0b0845..96c74c96c0d9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -95,6 +95,9 @@ static struct vfsmount *shm_mnt; /* Symlink up to this size is kmalloc'ed instead of using a swappable page */ #define SHORT_SYMLINK_LEN 128 +/* Like MAX_PAGECACHE_ORDER but respecting huge option */ +#define MAX_SHMEM_ORDER HPAGE_PMD_ORDER - 1 + /* * shmem_fallocate communicates with shmem_fault or shmem_writepage via * inode->i_private (with i_rwsem making sure that it has only one user at @@ -1680,26 +1683,58 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, return folio; } +/** + * shmem_mapping_size_order - Get maximum folio order for the given file size. + * @mapping: Target address_space. + * @index: The page index. + * @size: The suggested size of the folio to create. + * + * This returns a high order for folios (when supported) based on the file size + * which the mapping currently allows at the given index. The index is relevant + * due to alignment considerations the mapping might have. The returned order + * may be less than the size passed. + * + * Like __filemap_get_folio order calculation. + * + * Return: The order. + */ +static inline unsigned int +shmem_mapping_size_order(struct address_space *mapping, pgoff_t index, + size_t size, struct shmem_sb_info *sbinfo) +{ + unsigned int order = ilog2(size); + + if ((order <= PAGE_SHIFT) || + (!mapping_large_folio_support(mapping) || !sbinfo->noswap)) + return 0; + else + order = order - PAGE_SHIFT; + + /* If we're not aligned, allocate a smaller folio */ + if (index & ((1UL << order) - 1)) + order = __ffs(index); + + order = min_t(size_t, order, MAX_SHMEM_ORDER); + + /* Order-1 not supported due to THP dependency */ + return (order == 1) ? 0 : order; +} + static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, - pgoff_t index, bool huge, unsigned int *order) + pgoff_t index, unsigned int order) { struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; - int nr; - int err; - - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) - huge = false; - nr = huge ? HPAGE_PMD_NR : 1U << *order; + int nr = 1U << order; + int err = shmem_inode_acct_block(inode, nr); - err = shmem_inode_acct_block(inode, nr); if (err) goto failed; - if (huge) + if (order == HPAGE_PMD_ORDER) folio = shmem_alloc_hugefolio(gfp, info, index); else - folio = shmem_alloc_folio(gfp, info, index, *order); + folio = shmem_alloc_folio(gfp, info, index, order); if (folio) { __folio_set_locked(folio); __folio_set_swapbacked(folio); @@ -2030,18 +2065,19 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return 0; } + order = shmem_mapping_size_order(inode->i_mapping, index, len, sbinfo); + if (!shmem_is_huge(inode, index, false, vma ? vma->vm_mm : NULL, vma ? vma->vm_flags : 0)) goto alloc_nohuge; huge_gfp = vma_thp_gfp_mask(vma); huge_gfp = limit_gfp_mask(huge_gfp, gfp); - folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true, - &order); + folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, + HPAGE_PMD_ORDER); if (IS_ERR(folio)) { alloc_nohuge: - folio = shmem_alloc_and_acct_folio(gfp, inode, index, false, - &order); + folio = shmem_alloc_and_acct_folio(gfp, inode, index, order); } if (IS_ERR(folio)) { int retry = 5; @@ -2145,6 +2181,8 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, if (folio_test_large(folio)) { folio_unlock(folio); folio_put(folio); + if (--order == 1) + order = 0; goto alloc_nohuge; } unlock: