From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81868C30653 for ; Wed, 3 Jul 2024 11:25:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC0436B00A0; Wed, 3 Jul 2024 07:25:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B704C6B00A1; Wed, 3 Jul 2024 07:25:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A38A36B00A2; Wed, 3 Jul 2024 07:25:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8BFE56B00A0 for ; Wed, 3 Jul 2024 07:25:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 477C4A0B2A for ; Wed, 3 Jul 2024 11:25:26 +0000 (UTC) X-FDA: 82298210652.15.4B9BFE5 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 36FA480025 for ; Wed, 3 Jul 2024 11:25:22 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720005913; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XuQ2eOq9tQ/P4F+p67+qrw51DEnfkfy2st+EO6c2Y/o=; b=iXfTueHJhQb93ta8E/M0nUZ0g6zW34ea6/Q6u2RdjY9LjiHyWMlLl9Ve/HNi8A5q7cXwUo NosLgE019ddYGNU66y7wBq1GS+mh8l/U2577OkO4STSI/BTXwBLRkam/lq3QEOjd8w0xlL 5t0YHtdGn5i/5L8ICoLV1AIhttuH+80= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720005913; a=rsa-sha256; cv=none; b=cPvUrg4eYbFZM/YypUEsKf/l3rtsg9ZmRoIh8ybuTPxrJSqx8Iu3JTXWH1JFmo11VjeUx/ XmFfpbUj4ddxRG5bFx34NPKuoJD0fItR7lBS2Em1Xw3CY0uBAdDP9RO2AFGKi2j/bxbi/Q ybNw6jCXvsmyNEHS3CAAGEXnQlR0iCc= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WDcrX2cW3znZ3G; Wed, 3 Jul 2024 19:25:00 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 48681180088; Wed, 3 Jul 2024 19:25:17 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemf200006.china.huawei.com (7.185.36.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 3 Jul 2024 19:25:17 +0800 Subject: Re: [PATCH net-next v9 03/13] mm: page_frag: use initial zero offset for page_frag_alloc_align() To: Alexander Duyck CC: , , , , , Andrew Morton , References: <20240625135216.47007-1-linyunsheng@huawei.com> <20240625135216.47007-4-linyunsheng@huawei.com> <8e80507c685be94256e0e457ee97622c4487716c.camel@gmail.com> <01dc5b5a-bddf-bd2d-220c-478be6b62924@huawei.com> From: Yunsheng Lin Message-ID: <5b385269-bcf0-6bba-e2cf-e714fbd2b334@huawei.com> Date: Wed, 3 Jul 2024 19:25:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 36FA480025 X-Stat-Signature: jykzop9udiusdeyjfegipk71pnk4grfr X-HE-Tag: 1720005922-74867 X-HE-Meta: U2FsdGVkX1/PR6QKWavHKzrCICI/K4ywBRtnjF91Z8PPjRm6hlXdAzHyJnUyUNtTIy2v9cY3tXynbMnL+LHTmY1HjP5IZyQCY1Mr2RE99fgcXF/QL9HLLIpE3pGvmRLH6VP5z+ucFbRY3wsy3Hfq9b8QGKGyLH2SdrFRFBPXpngao65f2AP5vUxHj79W3Tki3v9ExD4JR9oXZ7ea/lcjfwKaUfXfFCjzZ0HLwvoDpPx+r8tidVU+g/5azjSle4UAfc/MCcnXuoOx1ej30TWla6qI4MV05kwBZXg8MftcEZBKeebJQKxFW2QeWHHo03wq67kLtHrEN/dRzbO8rPLqjdQfKbu3iQHIFnYF6qXK3xTRjnMVR3ae6uiYrI9rL+jw4NI/YNRvLiCeI+VSuymMSZG+iAAuHrgU3MW/suNXAFcsI6H7ncNyIQ2xkYpS4qbJ1QqQENcUvrQwtU8bw/6kvPWrpyx6AjxVV/RzqD+1CZzCoMRxU/4X1ZnaGubo7IWRkZnfLf4HWEJ2xxxaKvCE0Ti8NzXPlELkIY+PDXT5t6xMGQoU/i9IL8bITa8KBEmls8Q/PJEakPDFH+BPF9Lezi+KcX3So0ZMEN5gdHFkWSZ2L13bihzqqFoO75/tLlTA2hTv/St1MMHUYWvvoUVgIdaXEDNzKyqZL27lG2XYddr1xhOP0A2MMbNGuDkcOhcElBGrC+2WI57L1s7rEbL38fIDktEA4WkXDYt1swGICztA1DrqFDT4okTykxU+r0sYEZCBiyRMv6Q2NpXrJIgTDM2MXovdNRdVH38AEQaQ+f6OerCQcMHNiqWBMpbtUkpUmiEvtlmpFjMK/r1Q2hwuXVqaK/LWRqQYmWJ4SBs7mVypovjaP2SvgKEQJLMmYpN7xCJeVglyrQ54TKshx61fAJxEqicEPu7vZVKQIzYW/XfH5ehPwVZkTTDL+MFWmblSSpGvgjE3kaGy2xM3kTc axPLjiJh cGlwu5HxQjKVf8PmemBHJfRLrKCf/s8zmKZjQdF4MgqukuOTRqTRUo1lZoH2ZCyA0MMwRnnflcYGshNKYUZRB5HTyeGyRNAuChMnZr82ykmiI8edBqEfb7UD/1qKjSwfVsAFlFhteSLTEgk1Z9CfMcHYm4UUD7wLqfDHZgLwZD1PF+V+PCKzRuoEzEjxB6fh39248s6tckyR+KsmgiqTMSm6i1LLuB8Ip7i8GtyXzlBQvTZplAjiNhTGBtKHEaZPTIwYD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024/7/3 0:00, Alexander Duyck wrote: ... >>>> + >>>> + offset = __ALIGN_KERNEL_MASK(nc->offset, ~align_mask); >>>> + if (unlikely(offset + fragsz > size)) { >>> >>> The fragsz check below could be moved to here. >>> >>>> page = virt_to_page(nc->va); >>>> >>>> if (!page_ref_sub_and_test(page, nc->pagecnt_bias)) >>>> @@ -99,17 +100,13 @@ void *__page_frag_alloc_align(struct page_frag_cache *nc, >>>> goto refill; >>>> } >>>> >>>> -#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE) >>>> - /* if size can vary use size else just use PAGE_SIZE */ >>>> - size = nc->size; >>>> -#endif >>>> /* OK, page count is 0, we can safely set it */ >>>> set_page_count(page, PAGE_FRAG_CACHE_MAX_SIZE + 1); >>>> >>>> /* reset page count bias and offset to start of new frag */ >>>> nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; >>>> - offset = size - fragsz; >>>> - if (unlikely(offset < 0)) { >>>> + offset = 0; >>>> + if (unlikely(fragsz > PAGE_SIZE)) { >>> >>> Since we aren't taking advantage of the flag that is left after the >>> subtraction we might just want to look at moving this piece up to just >>> after the offset + fragsz check. That should prevent us from trying to >>> refill if we have a request that is larger than a single page. In >>> addition we could probably just drop the 3 PAGE_SIZE checks above as >>> they would be redundant. >> >> I am not sure I understand the 'drop the 3 PAGE_SIZE checks' part and >> the 'redundant' part, where is the '3 PAGE_SIZE checks'? And why they >> are redundant? > > I was referring to the addition of the checks for align > PAGE_SIZE in > the alloc functions at the start of this diff. I guess I had dropped > them from the first half of it with the "...". Also looking back > through the patch you misspelled "avoid" as "aovid". > > The issue is there is a ton of pulling things forward that don't > necessarily make sense into these diffs. Now that I have finished > looking through the set I have a better idea of why those are there > and they might make sense. It is just difficult to review since code > is being added for things that aren't applicable to the patch being > reviewed. As you mentioned in other thread, perhaps the 'remaining' changing does need to be incorporated into this patch. > . >