From patchwork Tue Sep 24 06:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13810156 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 783B1CF9C71 for ; Tue, 24 Sep 2024 06:17:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C42E6B00A9; Tue, 24 Sep 2024 02:17:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A3CC6B00AA; Tue, 24 Sep 2024 02:17:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7C2E6B00AB; Tue, 24 Sep 2024 02:17:57 -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 CAB1C6B00A9 for ; Tue, 24 Sep 2024 02:17:57 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 729451A1543 for ; Tue, 24 Sep 2024 06:17:57 +0000 (UTC) X-FDA: 82598626194.06.D00BBE4 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf14.hostedemail.com (Postfix) with ESMTP id 9BB6210000A for ; Tue, 24 Sep 2024 06:17:55 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OyoBGJD6; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.166.51 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727158588; a=rsa-sha256; cv=none; b=D4uQxLXM0e5Qq6/utyutOY8fnl98rdYajzipriwGieg6dwB40ISHVyDJlG85cW8RJeEROr QHJjXqQ7fYmNBZLxYqo8nY/WBioCoW38lPJ+qXYH/fcQgtqmUtk9wEKoJNDnsr6QvRGIc8 IjwlG24HRNXGiKoo+2yj/gTTHTQagxQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OyoBGJD6; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.166.51 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=1727158588; 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=Ux5aNP/oLGqsIM9y+xHY8KPmXx/0xGZ9RPGpTCoY21QI1NCoNSNdgapv0fD66K5kjBu9u0 Jzuhqz/5ap81fy7SY5zSMuwrDgmkFh+LN87a8vh4Xex7ptQrL9hE38AO6Bx6i/mLxx9VSn yw2v0WpG9biQV1ewpXkLc+gDLdfP2uU= Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-82aef2c1e5fso198624739f.1 for ; Mon, 23 Sep 2024 23:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1727158674; x=1727763474; 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=OyoBGJD6rp936tP7qbev6JYkJbfAWQ0HWMuMUupk3AmgcGRdSu2K2YcoCchWSMQZCz RIplzj/IYB5r6M91rgRmaKSltizuiKy2iV5+7Quiqo5kUZnqGYJd/hS6AS7iAcgKZkXh 8r88IXuDg+m2h/6SS3iN5TOyTJIyrelegcfXffouAgY15NNkQiFoeogDuE8QTxiiLFwW 01y7N6bKpEtU4yEFr/tdtEUgVPqN9Hmo+yK15lKqbJ/zUXr4Nf3Ezs+5wjBbmStqYVb2 wB/rJ6qK2KtXoEdCWt7OUtF+iOpHnf1+xb2KnLgrugaO8QTvGvHPHLVJpGee9joOC5wx PjGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727158674; x=1727763474; 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=BOrBV6B/kJmKXTdyQ2KNuKUEDefkn9Fu+KtpHocpwE0xfdvVmbBUTtWpkQLTsrGqL1 lUgN3tkb7Bhd47oDp59Oe9DH6PNzb4zOERk6IL8Hs18HC4rQ9HgDv5xGj2kgV6WnLgQj St+1AGSBax4nWff659pIC/Zu3g5a3bU4g80JRG3Dt3mbLE/QEgnA6GNI8xAxqZTwZMSl N0MJEGFcXBHMIf4KsOzy3Un5WTAsxaavOtesRJAv3egdkzwTvrMWOxY64VDS6neL9x7v qDGxEuS6h2asonF6G7x/F7qFw+iWuHzi8nLV8CIrv32HoI+1CKGzqg10ZYKiUI3PRu/3 ShSg== X-Forwarded-Encrypted: i=1; AJvYcCWrpus4X2rLNWp6u+NHeRE2TdW4JRlWlbJkOOuqBAMMVW4s5OfYSE1vJgsTufiaw10QnYxQp9LJGw==@kvack.org X-Gm-Message-State: AOJu0YxJwxjrzReH6RxjNd9vGuwkEEMH27epSrnC4CeBEdPp3fKI6YsV 5VQ2E1yVwMNgTwIolSngIckLIJQRj3xICW+pQrfHtsGg3CdXVDAmLmjku59gqsOKBEjC34Wu1vZ sHak= X-Google-Smtp-Source: AGHT+IEXIad82sT4qTFz/mgMdJh1108B7x8i2K/1dZJvW9IHButimBDIW5JZoOsyX1eaQQUsC7JSYg== X-Received: by 2002:a17:902:c94c:b0:205:4a37:b2ac with SMTP id d9443c01a7336-208d83c8698mr211905735ad.34.1727158253643; Mon, 23 Sep 2024 23:10:53 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([63.216.146.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af17229c9sm4344885ad.85.2024.09.23.23.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 23:10:53 -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 v4 04/13] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock() Date: Tue, 24 Sep 2024 14:09:56 +0800 Message-Id: <69e1c4483c2d679d3e2c8446264e5878e5b52a97.1727148662.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 9BB6210000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ongt9yjzyy3jc9j8nwiaf83ju6igpax3 X-HE-Tag: 1727158675-888837 X-HE-Meta: U2FsdGVkX18i5InrweiS4yjZ4BuaYgUREGNc1F1N0xyIZzDZXdviGYdW4/sPxgkssV++5ZN4P+0K4das2d6RpEpwj5uATb8hqYsFM4Ap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wFo2t8+c2vS/jB7CwOhrfxB6/Ifyk91nUk+p9+t/JUFbcgCkXukrKf1QWbSZrfqjBIn2ymcrrBLcBmuWQt+tNhEpvwAj1ZvGWR4z+AnmIzDB6oytQyyBq8a4KIrcTIvFU5TXASQikntxYn34t0crS26yeQiwpwT/UOexfH83IijFEfY4hKkotJ0GG2x0EkIKZbItwM8YRRKra/RbxnUMoroh7VY1b6m3Y5OMf4VrTJcZ9v++s7EfaiOTD7Bp2hd8TSrQ1YqTG8Il60AGI4E1Y= 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;