From patchwork Tue Apr 2 02:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13613275 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 68BD5CD1288 for ; Tue, 2 Apr 2024 02:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6CCE6B0082; Mon, 1 Apr 2024 22:50:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1C6D6B0083; Mon, 1 Apr 2024 22:50:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0B466B0085; Mon, 1 Apr 2024 22:50:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9A0436B0082 for ; Mon, 1 Apr 2024 22:50:15 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 21E4A1408E1 for ; Tue, 2 Apr 2024 02:50:15 +0000 (UTC) X-FDA: 81963062790.18.6C8FAB1 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id 2E8BA40012 for ; Tue, 2 Apr 2024 02:50:11 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712026213; 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: references; bh=vLsYA0bDX73q1xew3GPPFMcVhHkFdUHb4EVkL3gaS4w=; b=fNzM6nIe7lgsF2NOKEUXJu7GoGV3oig5XQUEIav+llFwAWpI6nTj6JWhO7R+MfaiCJIhal +cBHiG4gS17v+EgzySoPBXhjBMxdS3e1EXqvZsvnteSutfAccOZU/qrrnw+b4IGCpfqZwH 0pxjXNhoDaRL2o+XCKFpKK14anQSReE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712026213; a=rsa-sha256; cv=none; b=wd9Gp9x4eJw6NADWcML1HkNrqS/lgorsFIo8xT4LmpPRzMCZSk6LeJJkNRJaNeFKg4MWhh mwPpKpLPJW2I2vBrmHq0nOyG3+Lk09f5p4QcB22+5EdVrWYRIEf46KL1FBdOtXPkjGU3zI E9sDTC3qC6qFNeTNhelD5fs0mX8q6Hs= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V7skT1FsLz1ylXG; Tue, 2 Apr 2024 10:48:01 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id CC4D2140124; Tue, 2 Apr 2024 10:50:07 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 2 Apr 2024 10:50:07 +0800 From: Jinjiang Tu To: , , , , , , , CC: Subject: [PATCH] mm/ksm: remove redundant code in ksm_fork Date: Tue, 2 Apr 2024 10:49:34 +0800 Message-ID: <20240402024934.1093361-1-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500011.china.huawei.com (7.185.36.84) X-Rspamd-Queue-Id: 2E8BA40012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1k7kcgt9tcwq68u1fkryrf5s7zag9tak X-HE-Tag: 1712026211-687694 X-HE-Meta: U2FsdGVkX1/PPVMWLWw6QW8miBs3At0amx7862A1pjNP3UnL0Kee85rhTDXum0A7nuBC7gHOoRVJLWMFoAY64NiHd0JzCKxtDe80S0xcneKIOkIPU2pOtZGrw7NxzIFGYd+2URSFZDVPtrOz/pz7jOVsnhcXGkOALVoo7fvqFAnu66V4LZOVec3HP5QAPrHom32hAn2w10+rglrxzmoLe1t9Qn0Gq5Cs6V5DeXT70XtgDOncR85zA13irz00gpQNFiwwJPsG36g4eyLuEE7eLHpWf2Egpp5kEh3jruIZY2KkcCHlosw4Ekoh80vhyUbDkqCLSqVAJD/yJNy0X5yVSXrNG0AmQBoyjwElykV1iQ38sV0G6d33dBxRfW/QiwQQqpApI5kaQuhs6d0pNl0Ie+i4eg1GYflJznhPfgy7lBi4FC+9sOeUEeqOut3e3kboLau/27oXFeKutEC+I9mHkBJ+oVXdF9wNfdeXEZDFiibihV/Zedg5mQ4RteI81INLBrg4dTMmmmZwqs+/ZCmrhrFB0gjfshzhK9EoSkvIjvy9UFeLFpjYgnNVa4ATc7TFHUx6LnpQLSn7M3ygLkiCh3DOfkz8M0SF8z42Dfld3H4m/s369MIwKMwSZVJMgpHgh0ZS5xlYeF6Rd6GlqhNx3LAyJAoghxUqgWE06izFOErTlED02SEAeGcu83F/zqVIs6MmowLvBMnfAKneoFXU5HEL+AC6pulsD22HvaPbB/GRWLxoXK3is8t1Oq5frqiG0QPObeIbLQ0HgcYQoksmZ9mhmG1fs5FaAgRcJSIv2JKcGDAoyxSGKRaC3HF8ikZRsTZKlv3n5LuhNatRzv6HhWgRVFbFXyGlEvxuRejA69SHj+b32P+m6h3gSqgsxVOjQmWzqMeZkkAXNN0hB3dO1wBgiht7hRwqZ4rhOo/gRiqvF3latxjwDngt9EpUHPjgW2FZu4sp0NK/Jn2z2ff TbWz7m4I iyQlGp9k71P69p+8spcC9rj4Kd80fJX8MES/kNsPfcowDipDO6Hh5fTjlb1hiSb7W3//EvU3Jdt0G5a8TnR4aAtGAv2CMPBa3xJ5VBNnzVjQGnnT5ip+TcmkwuIdxg5qOYXg/Z5Wg6KsG4qD2MhjNocZrD7RhEYyQH54vLA1jwLtAz663J113HIqbqtye8B/kkAg7 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: Since commit 3c6f33b7273a ("mm/ksm: support fork/exec for prctl"), when a child process is forked, the MMF_VM_MERGE_ANY flag will be inherited in mm_init(). So, it's unnecessary to set the flag in ksm_fork(). Signed-off-by: Jinjiang Tu --- include/linux/ksm.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index 401348e9f92b..2e61df795803 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -45,16 +45,8 @@ static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte) static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm) { - int ret; - - if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags)) { - ret = __ksm_enter(mm); - if (ret) - return ret; - } - - if (test_bit(MMF_VM_MERGE_ANY, &oldmm->flags)) - set_bit(MMF_VM_MERGE_ANY, &mm->flags); + if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags)) + return __ksm_enter(mm); return 0; }