From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07E571C6A5 for ; Thu, 26 Sep 2024 12:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727355524; cv=none; b=f3G2B1E+Am/wJSfb7muWz//JbkGVLboO4O7UhR6v8vl6T/Y2wgqnnfT5hXQWU2YypCucoA+5dGZhQFAaXXvw/wR4LcdZBj6Al/qPsWRElc/+fcUeJ4mDupGneR2Q7faqwwIQcTMjd1lIhtGdliYwe911xOhShAEbPtGnUvtKxsY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727355524; c=relaxed/simple; bh=SmtIA7XYQx4nX6+fGbTqnqCSm7yRmL3RORcONRWqcWw=; h=Message-ID:Date:MIME-Version:Subject:To:CC:From:In-Reply-To: Content-Type:References; b=mdtgkd5WAwVg2hiVVRGrudSxQhQIi5IqEh2To/Jg40/nt3yhaT0zAhgWoHEL0PWbb7O/QrBAL+tOGGdJ0V8trmr0pgmcIPDs5JznLp7xtXoUtAjDB+x3HKSvQinK4MbJRAiZ5IfpKtKNXM6sIhCf23re5D4i/T36JwLYmtCTARM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=VKJ1HVFn; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="VKJ1HVFn" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240926125833euoutp01acb87cc3f5966ba5e9cf20930e5df610~4zLAeO1UV3237432374euoutp01G for ; Thu, 26 Sep 2024 12:58:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240926125833euoutp01acb87cc3f5966ba5e9cf20930e5df610~4zLAeO1UV3237432374euoutp01G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1727355513; bh=da4ojY3FKYoZj4Metcz6gYoYuDUssygQUDpJ4V+FW2E=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=VKJ1HVFnPZeq8nQMYmyC+lMUhP8B1KnE8EWyHrSqLEuLnIWjA1Y1jgqGFtrelpsoJ tM2mErwTNcT+DPgRem2GWVl1CH7tTBaINNGNLFImbzIeB+ubF7gI+I4sChKu3/IoGD gqBFR1G2Iw4i9jGM+9lxS+dnIQmMdvqRbKfIcHJQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240926125833eucas1p25553c8da37e5630ef564cb2acbd36260~4zLAMjar72928829288eucas1p2t; Thu, 26 Sep 2024 12:58:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BE.1C.09624.97A55F66; Thu, 26 Sep 2024 13:58:33 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240926125833eucas1p16d318f89b21db92af582be778eedde4c~4zK-rIBcH1657916579eucas1p1I; Thu, 26 Sep 2024 12:58:33 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240926125833eusmtrp26c051f0c4eba6a7cea62b08023158779~4zK-pSTV31891318913eusmtrp2T; Thu, 26 Sep 2024 12:58:33 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-d1-66f55a79a688 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C7.90.14621.87A55F66; Thu, 26 Sep 2024 13:58:32 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240926125832eusmtip28fa82999f1ebdbf9b8ef66fbadcb8178~4zK-dGYMa0982809828eusmtip2c; Thu, 26 Sep 2024 12:58:32 +0000 (GMT) Received: from [106.110.32.87] (106.110.32.87) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Sep 2024 13:58:31 +0100 Message-ID: <18532bd8-08bd-4494-a3af-fe252a803380@samsung.com> Date: Thu, 26 Sep 2024 14:58:31 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 1/2] mm: shmem: add large folio support to the write and fallocate paths Content-Language: en-GB To: Matthew Wilcox , Baolin Wang CC: , , , , <21cnbao@gmail.com>, , , , From: Daniel Gomez In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7djPc7qVUV/TDP79kbH4fFfIYs76NWwW //ceY7T4uv4Xs8XTT30sFot+G1tc3jWHzeLemv+sFj27pzJaNH6+z2jx+8ccNgdujzXz1jB6 7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eai4kQAmuoMhJIDAAA= X-CMS-MailID: 20240926125833eucas1p16d318f89b21db92af582be778eedde4c X-Msg-Generator: CA X-RootMTR: 20240926121649eucas1p2aec9398cab6db6fee1251a1a61568857 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240926121649eucas1p2aec9398cab6db6fee1251a1a61568857 References: On 9/26/2024 2:16 PM, Matthew Wilcox wrote: > On Thu, Sep 26, 2024 at 04:27:26PM +0800, Baolin Wang wrote: >> +static inline unsigned int >> +shmem_mapping_size_order(struct address_space *mapping, pgoff_t index, size_t size) >> +{ >> + unsigned int order = get_order(max_t(size_t, size, PAGE_SIZE)); > > Why introduce the max_t() call here? Did nobody read the documentation > or implementation for get_order() before writing this patch? get_order() result is undefined if the size is 0. I've used max_t() here to avoid that case. Perhaps should we prevent that case before getting here? > > Besides, get_order() is wrong (at least relative to other filesystems). > get_order() rounds up instead of down, so what should we do for a write() > of size 512 * 1024 + 1 byte? Other filesystems allocate an order-8 folio > plus an order-0 folio. This code would have us allocate an order-9 folio. > I think that's a bad idea. > I think one of my earlier attemps was to use fgf_set_order + FGF_GET_ORDER() as in iomap. But the solution taken there was to share code between shmem and filemap and that wasn't considered a good idea. Shall we just replicate iomap_get_folio()? Or else, what do you suggest here? Daniel