From patchwork Wed Sep 4 08:40:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13790093 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 8004CCA0ED3 for ; Wed, 4 Sep 2024 08:41:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A9DF8D0238; Wed, 4 Sep 2024 04:41:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 032CD6B02BB; Wed, 4 Sep 2024 04:41:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC7808D0238; Wed, 4 Sep 2024 04:41:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B3D826B02BA for ; Wed, 4 Sep 2024 04:41:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 712B6120E24 for ; Wed, 4 Sep 2024 08:41:19 +0000 (UTC) X-FDA: 82526411478.15.C200A7E Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf10.hostedemail.com (Postfix) with ESMTP id 99FF8C0008 for ; Wed, 4 Sep 2024 08:41:17 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WPeXY1mh; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725439171; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=1YeM5kHJFa1AZZRHBSnh5o5C+SsIPAnH1bO7WEMZ52g0KgM7Ab8yYnecOHBb9O72NHd0Vr JimyWbZSmnUjtkaUSNZlFBUVWdFCwf9KrSp07VmVHr+JTktiJTuxwSE62oLqA9cA37F+SH fOXoHGSIHBtQUUTuwSKC/5gPAB1IjVU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725439171; a=rsa-sha256; cv=none; b=J2zXI+cTYaOoRt0vbmFOXhhD3yd1yzWm9J1RFReam0vyYppsJWIrP7l3Q9TAG7O0DdnMwg GcdpwKnaN2mzZsCyHKmOmKPlNTM0Ua58fqhMEPXNSncCKycENmasnMisCrbY1s/SNA12Gx xUy+Zr63R3TjlrO0vOFU9iV0lB8AzqM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WPeXY1mh; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7c1324be8easo354984a12.1 for ; Wed, 04 Sep 2024 01:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1725439276; x=1726044076; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=WPeXY1mh3sj6DOqJafnntfjvhqaDxxDRN+7MztkbazIW7srb5qiMekPdZMUBB9tGGW atUTzx9/rc4ZHts1t9hkRrYUsMKCFx1HkcJb8k1CgQJl9nGorsDArGTzVojSYkkxGibo fQ7TRx6M0luZucf1eD5tIkxqfADrnplO3QJf/o+lzgAlqWwfbuZvib4T/zE8dQmgu8oc 8XgWDT3zwKAO4lEgp2pBGLhct6w8Dm+qprZodlhtBfLEGB1vNmvXOyoA5YvMTVHdc9fP 6jx+vCfGClaDYuXzhvTsuffVElbKWnMmmcr+DRKoon34vXVY11lLiMW9d5f5mbl+Os+x 4RzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725439276; x=1726044076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C6e2rRMn75kFV6Fv258+yl1EB6KpOV48BOzHpMuHQ/Y=; b=pdfJeFD0m7Id0CeEpjRxoWGY0Asiof3lGnrB2jqd3r/p1CKvR3GRDBbO6b3AluOYyB PQ5C+ef5eLqzdJfPOO6WWhJL5sCLU7WfGC2t3Zcei4QQ3sZ5yrqjoEXbk3/HzXnm4crc mnqFWnQC4A5z0hd57IRbwkvGDA3CV0GmZ/KHH0cdW5/fN3hVOyfj5rOinAuNKj3DG6Ma bka0KlnCyvHDDoJX2gvfabbKSHxTZzcCdih2Cls1gIvo3oCmffgWyDl2INznmtWZvFdZ 22NZnz2muMengR0F+AaJ0Qn6JIL+/UykF/qS4zWm72HrCXoQQzkUNkq6H3QFOc3J/MP6 tUAg== X-Forwarded-Encrypted: i=1; AJvYcCX1H8vh64KG53oozztLWXjJZGdSk8amFmftPhdJzSuFOHVoOZ9Yb0avgye5IGzuGvWaa0cxRikz6g==@kvack.org X-Gm-Message-State: AOJu0YyZdz5XBLDBwbyRl9/e7XTKFcTQestAHpFKQt2uQ90+R5fYXPI2 brT7XBEGCognxBynPcZOW5Pjur/v3DkJMi6Gj6EfdjiJmFuxFXUBUjwuPbucIaw= X-Google-Smtp-Source: AGHT+IEy+qEnEqpj3sReiKH3tPFUkwjqR7spuVkWXeQJodyHWsfCM0cenE/z+pCdCppofQTZA+ekKQ== X-Received: by 2002:a17:903:283:b0:205:76c1:3742 with SMTP id d9443c01a7336-206b7d00d3amr22901025ad.3.1725439276249; Wed, 04 Sep 2024 01:41:16 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.242]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae95a51csm9414045ad.117.2024.09.04.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 01:41:15 -0700 (PDT) From: Qi Zheng To: david@redhat.com, hughd@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, akpm@linux-foundation.org, rppt@kernel.org, vishal.moola@gmail.com, peterx@redhat.com, ryan.roberts@arm.com, christophe.leroy2@cs-soprasteria.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Qi Zheng Subject: [PATCH v3 05/14] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock() Date: Wed, 4 Sep 2024 16:40:13 +0800 Message-Id: <20240904084022.32728-6-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20240904084022.32728-1-zhengqi.arch@bytedance.com> References: <20240904084022.32728-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 99FF8C0008 X-Stat-Signature: gua8skenxswxuts6mw6cahhe5b9rm6zf X-Rspam-User: X-HE-Tag: 1725439277-294836 X-HE-Meta: U2FsdGVkX19Qyu1UhqZMm309R2GiKDmUBYaggL9v+Gz3kjA7bDg6LPfpoyUFUG3dRACFpBkvQeKb0iy7EYDstxRIy2hmnkwwzuU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IC4TyJkwMhHGPRQsjc7WhpJ+Adzb86sxbeqCgWzRXnNTnG5TsnCrFAdTqPewo2lnV/c/hGvR+jrZKYqP7I2aAHx46NNErizw9zuof/hUSWg7ByInZmzyuWPLxmmkemhyVY65IsVnmxCXLvgKmp0LzBWBvLGTZZzzVo4UQpD3nDOq0ywhsdzh3rts6LMxkNDsHgopu3RMC2lnj9mhG2QFZke0qz40fmQ5UILWdU4hM+4VIKUqRdcH3Cj/tZKY+Dyhb8HffybHz/TMV4wq1pPY= 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: In __collapse_huge_page_swapin(), we just use the ptl for pte_same() check in do_swap_page(). In other places, we directly use pte_offset_map_lock(), so convert it to using pte_offset_map_ro_nolock(). Signed-off-by: Qi Zheng Acked-by: David Hildenbrand Reviewed-by: Muchun Song --- mm/khugepaged.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index f9c39898eaff6..6498721d4783a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1011,7 +1011,11 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, }; if (!pte++) { - pte = pte_offset_map_nolock(mm, pmd, address, &ptl); + /* + * Here the ptl is only used to check pte_same() in + * do_swap_page(), so readonly version is enough. + */ + pte = pte_offset_map_ro_nolock(mm, pmd, address, &ptl); if (!pte) { mmap_read_unlock(mm); result = SCAN_PMD_NULL;