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 C8E29C3DA6E for ; Mon, 8 Jan 2024 08:21:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57AE06B0074; Mon, 8 Jan 2024 03:21:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 52A666B0081; Mon, 8 Jan 2024 03:21:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419776B0083; Mon, 8 Jan 2024 03:21:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 25A9C6B0081 for ; Mon, 8 Jan 2024 03:21:01 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E28231A021E for ; Mon, 8 Jan 2024 08:21:00 +0000 (UTC) X-FDA: 81655448280.29.0923ECF Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf07.hostedemail.com (Postfix) with ESMTP id EEBE540004 for ; Mon, 8 Jan 2024 08:20:57 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.189 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=1704702059; 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=OZ3ZWLPclzyBse30Q844c+F0WUp281iw0yozFpufvlA=; b=DsHaGIH4KN9lCUUS9g5tn75YjS/frQMmvv997r8hYt0KCHwGo/3Mr2XlBCJLYzoXX6b7q/ 27Jlb3b0OzCYTX8JEEgiZ25jlldAUnF/4A4nV469jix3J/cUdqXf0gabcS8T1KIepwH9lw 2O+kSitUaNyfdPaWgRcPBgSPEvyDgfE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704702059; a=rsa-sha256; cv=none; b=Eo7GBj37ICTcCYQw54iiNMLBJ5Ja9PljnIgsPMbd/nwjUp+kpfic10SgJkWrpWY5U/RvKS qKU2nexCvsnNSBPX4NmLTDQ1JEIVwdSVwuqITxM7xazXtQrjy/+1PXPp4Z70XvwN8dEuGU 1uh9Pm8TQ3Rl4oAYfNa8eO5cQ10QrVs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4T7n761B8HzNkfT; Mon, 8 Jan 2024 16:20:18 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id A18E6140518; Mon, 8 Jan 2024 16:20:53 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 8 Jan 2024 16:20:53 +0800 Subject: Re: [PATCH net-next 1/6] mm/page_alloc: modify page_frag_alloc_align() to accept align as an argument To: Alexander H Duyck , , , CC: , , Andrew Morton , Eric Dumazet , References: <20240103095650.25769-1-linyunsheng@huawei.com> <20240103095650.25769-2-linyunsheng@huawei.com> <3f382fdcacc10cf897df9dc7f17c04271839d81a.camel@gmail.com> From: Yunsheng Lin Message-ID: Date: Mon, 8 Jan 2024 16:20:52 +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: <3f382fdcacc10cf897df9dc7f17c04271839d81a.camel@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500005.china.huawei.com (7.185.36.74) X-Stat-Signature: o4u4fftfi8jygmc4rytdd9agr7pg9nuu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EEBE540004 X-Rspam-User: X-HE-Tag: 1704702057-412595 X-HE-Meta: U2FsdGVkX196RVpSqGUAXcy22dayOfQ9qk9QFYbepyPDPqaDePt35nZlFVPc2i7BfDZ5Bp6Vnnz22OAFPZb9iS3z8FcpJ92hFraUj0ir/v7hGM/NHApGk0qB7UtC+rW/G9kIghltOPvvxf1+YXGI/bi8QOvmPsrlxKXn4jGYvWiv1hj9CJsGFG1ygEwaih4mj/aVjfqZHH4RBDVDxN3rNpVi/smaWqmEkMjF681O2xQ37tEhTeEffByYo4dBiAFdxApbe6tBrG0nTbF+akAm3fjGZI707/Im8Z3FIOIL/kuEv/nRYWEH5J6L2ad1sLYWfA2i6M8WeGLn2BYuqKdGnFr0c8VRLK+GILEiQfd2W0xpNKZzKc2F9slX8PEngaOvkx0tn3/OZy1ojbRjiNEkyPjaPtuF1uDhD7u/UV/mXFmK304E1nlmjH2o3Gb9R+Ur+gnF5/xab8imboPXtYySzqp6An/pZ4oTfk15Z4Pc3mUhQ9nN6vVPTvfW7xu6MaKH58Zvy1vOQbUmUO5yhCfD0VIv46l7JJ4RUux6lDOYiS+kaXH2v8RylcHFmXWRDEYCF4AkSN8VoqkKiuz/IkZo3fH0L+wroPEATNSCy2HyCvwaLQG7jto6jRGNXenZBncKdHeZuAQSG3vlMbq/OLBPsoryCHfvgYS8pF1sGfQY87IVOZW/Wgu88VHBtVcdyy26yiQelJI+cAS4I+WYKvKNNQyx/PZVQQQO7JLKgvwHsIHRZKXRyogxfAUlZOFrQnCRofjdbqaaRmua7SOilftgYA1JhL/88fVfsWQjTK2eavT68QW3Q9tOHJ4l4ApK9KcXLr50/c2kf32cyF/THQrDq6Ebafx0xnC/SmyXMmP95mIg9fAEBaui8GsvhpHgmVdu0mYISjdiJ8bP6UabSVfHl9onDURRudM3kcpBu5GZx2ealnjMH9RtJJL3Qn4Wo5wTcW0LJ++uWNXrTm3Ziqr twOCo6tA yHcJv4hUEBbJ43ouPsoQjiG0Nnapkw9kyFn3gBg1tkicNItrhqAljVeYb1DVngYIF6yk9eHxyZDkJ5F5FlpZwJ5mSJ4+3Uk6wMu4cbcboS8g/ZSq/34xEucJ5YJWcufNxo4TiSsCN3PIJegcB5grA0Pl4QvI3dawIlWUjmQ0APE7gWzRWbMDTaJPrhWmWObuc8WZSE/qqxXfOxRcmD13U3JDdyzGPiJibLKy9TgQk/1PrmpCDBBUyPbHvQUKirL9rD/pONJ6ULclvb7Mb9XtkVRLmL1hXSilabRlNY5K5llqFzEA= 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/1/5 23:28, Alexander H Duyck wrote: > On Wed, 2024-01-03 at 17:56 +0800, Yunsheng Lin wrote: >> napi_alloc_frag_align() and netdev_alloc_frag_align() accept >> align as an argument, and they are thin wrappers around the >> __napi_alloc_frag_align() and __netdev_alloc_frag_align() APIs >> doing the align and align_mask conversion, in order to call >> page_frag_alloc_align() directly. >> >> As __napi_alloc_frag_align() and __netdev_alloc_frag_align() >> APIs are only used by the above thin wrappers, it seems that >> it makes more sense to remove align and align_mask conversion >> and call page_frag_alloc_align() directly. By doing that, we >> can also avoid the confusion between napi_alloc_frag_align() >> accepting align as an argument and page_frag_alloc_align() >> accepting align_mask as an argument when they both have the >> 'align' suffix. >> >> Signed-off-by: Yunsheng Lin >> CC: Alexander Duyck > > This patch overlooks much of the main reason for having the wrappers. > By having the in-line wrapper and passing the argument as a mask we can > avoid having to verify the alignment value during execution time since > it can usually be handled during compile time. When it can not be handled during compile time, we might have a bigger executable size for kernel, right? doesn't that may defeat some purpose of inlining? But from the callers of those API, it does seems the handling during compile time is the ususal case here. Will add a __page_frag_alloc_align which is passed with the mask the original function expected as you suggested. > > By moving it into the function itself we are adding additional CPU > overhead per page as we will have to go through and validate the > alignment value for every single page instead of when the driver using > the function is compiled. > > The overhead may not seem like much, but when you are having to deal > with it per page and you are processing pages at millions per second it > can quickly start to add up. > > This is essentially a code cleanup at the cost of some amount of > performance. > > . >