From patchwork Mon Dec 9 13:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13899767 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 7382BE7717D for ; Mon, 9 Dec 2024 13:26:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41AE36B043D; Mon, 9 Dec 2024 08:26:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BC2C8D0059; Mon, 9 Dec 2024 08:26:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 261AA8D0058; Mon, 9 Dec 2024 08:26:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 05DE76B043D for ; Mon, 9 Dec 2024 08:26:02 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9F3CA12024A for ; Mon, 9 Dec 2024 13:26:02 +0000 (UTC) X-FDA: 82875493386.16.8CC1A91 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf19.hostedemail.com (Postfix) with ESMTP id 3BE871A000D for ; Mon, 9 Dec 2024 13:25:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of ruanjinjie@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=ruanjinjie@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733750751; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oqnQIHI2YMQJ3EkVHBMVinxR6ND7w0RifOrNGdS9aRY=; b=LdJ2ZeeDZOxOywwSVULuVUD73PjF+k7QfhXYLqwOVAIIqWAH2tpsggNDc61hXYDuHzRWqa LNxzSu0HzB+2MoWIzJCsy5e45oTANQohjlih3MlHxYhkO3ozgCpkV6E2qmQF1QUH72/Nc1 Vifgecp10pn+5YFNmgWYVZj5VDBCNZI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of ruanjinjie@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=ruanjinjie@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733750751; a=rsa-sha256; cv=none; b=6K254vKzUjLCXInBnmUt56Pi66M//IpskKmCD+NhJ/DzSVECdlCgmDoO8vJTMK8sgna+IB E+iEnJ3jUr3c7eWZK7rJNwgmmrCABHqqGQIeXQs9TbDu+e65hH9F338AImTpfHWmRG9PFe DiM846O+6ofhi9/xdIz7Hir5vIkLm1k= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Y6N0R2QZwz1JDvw; Mon, 9 Dec 2024 21:25:43 +0800 (CST) Received: from kwepemg200008.china.huawei.com (unknown [7.202.181.35]) by mail.maildlp.com (Postfix) with ESMTPS id 6AC0A14011D; Mon, 9 Dec 2024 21:25:56 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemg200008.china.huawei.com (7.202.181.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 9 Dec 2024 21:25:55 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , Subject: [PATCH 2/2] mm, rmap: handle anon_vma_fork() NULL check inline Date: Mon, 9 Dec 2024 21:25:49 +0800 Message-ID: <20241209132549.2878604-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241209132549.2878604-1-ruanjinjie@huawei.com> References: <20241209132549.2878604-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemg200008.china.huawei.com (7.202.181.35) X-Rspamd-Queue-Id: 3BE871A000D X-Stat-Signature: tybzghibdwhkpfuukku551fr4pptsdpz X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733750737-808931 X-HE-Meta: U2FsdGVkX1/TKRR3Zr8nmmNUyMMjOAPbXf/gU6U6hOzipevIZdCxl8rqSKCafIlGfcVbvTyBu3Q/67QpEsbiPgXvbG4Zdi3UvXDZuYODcGZ27IPau7Zum3v78ie3vUBVbQb09cRAi5grnWd/dxCIjFDOE6j9xvknwhOXMPo8cuEcs4pmAPvJDl/2Xq9iGCCZYfKP1HQu38uaAosH6Fqqk+lD72EJUhFjVNtmH807SRvJwTWR/bBINSJ0TAq/UdQSaK7KWNbrC8JgCufUv7gfh2ovOcOxXNHbcOQpKV+OLKrBw1Cy1Kjskj5AU/3lBogbngujtrk6HqUxeglcMBe72JtARkJmSe1Kw9ZFh0NkjqEV8UVk1OzfQswsIAXIJiWg4KNJxqYwBmjRvylzCwd6gmBkZbA3WPAAKkqOFJlxSoDr3v/H4jNI/0aYFvzpTvSz6Otl6DRZvk6tWH8gx3NMMCwGi40db82J6AeZLR8Lu3uqK7ErfwU4Pl15eN7TjSRpOHXF/dUaFwqRi+Bpd2dkABH6caj7irFkNpUfWwtiAIBz7d3f7Oz7McrLEQfD5KgsD3XUDQk6o8ZjWptlKZvsJSbfGi6BCLYYfX4xZLzbzOgJg1oR2PRWGlHJ1e/WaQQ0Gi5NMrQSGiQgsmW9tZuuo9/dkS+LSQdrjL/1mt3jLZUtqworLmE1XcuwCRKD8SOKcZXADKWDyNhBLLaFOpVUPA1DS4Js7FxOUvsjwfkYHDjMWr3fkAS6WlNdqYaMyMzzKZe8zDhx6oI89I0uoCajwF1BIu4/9Wt5adtI3FycFOQhQl2fPxHMhXalPeis9Wy/qTQbduMSmJ44BjYTvGvphtGarcT8rGwOyJVOtr3V10t2NaRz5P6Y/D9oJI2o0iifwe0UjPSDLcJHg+q+YC44WQ/ra/Tf+McuPpiCcIO4iZigXLwkBO+uZQYsWMcC7zaHWk9rcM4B28GzaEAaDcE V1YM0/+A RnZJ2qHMg+kvnC928mug98F0bA52qhIUNL3myNxvQ01Ymf/sPgP3KRxnZ9+ZJnE7GZPqiYeqyTEoUBqRnKmoeWnlnow6pAxnoNnm4vEDULIv+S6PXqhwPjEI+yJhHAVNjqV89jfKzKhV+T7uiOATOs9TnF8D9v6/qYoYx/gTpjz7KEf97JgHwIjl2Va0/EirOVBlL 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: Check the anon_vma of pvma inline so we can avoid the function call overhead if the anon_vma is NULL. Signed-off-by: Jinjie Ruan --- include/linux/rmap.h | 12 +++++++++++- mm/rmap.c | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 683a04088f3f..9ddba9b23a1c 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -154,7 +154,17 @@ void anon_vma_init(void); /* create anon_vma_cachep */ int __anon_vma_prepare(struct vm_area_struct *); void unlink_anon_vmas(struct vm_area_struct *); int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *); -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *); + +int __anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *); +static inline int anon_vma_fork(struct vm_area_struct *vma, + struct vm_area_struct *pvma) +{ + /* Don't bother if the parent process has no anon_vma here. */ + if (!pvma->anon_vma) + return 0; + + return __anon_vma_fork(vma, pvma); +} static inline int anon_vma_prepare(struct vm_area_struct *vma) { diff --git a/mm/rmap.c b/mm/rmap.c index c6c4d4ea29a7..06e9b68447c2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -331,16 +331,12 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) * the corresponding VMA in the parent process is attached to. * Returns 0 on success, non-zero on failure. */ -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) +int __anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) { struct anon_vma_chain *avc; struct anon_vma *anon_vma; int error; - /* Don't bother if the parent process has no anon_vma here. */ - if (!pvma->anon_vma) - return 0; - /* Drop inherited anon_vma, we'll reuse existing or allocate new. */ vma->anon_vma = NULL;