Message ID | 20231204172646.2541916-2-jthoughton@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 5A11BC4167B for <linux-mm@archiver.kernel.org>; Mon, 4 Dec 2023 17:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E960D6B02AF; Mon, 4 Dec 2023 12:27:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E46866B02B3; Mon, 4 Dec 2023 12:27:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0DF16B02B6; Mon, 4 Dec 2023 12:27:11 -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 C00096B02AF for <linux-mm@kvack.org>; Mon, 4 Dec 2023 12:27:11 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 97C7C1402E0 for <linux-mm@kvack.org>; Mon, 4 Dec 2023 17:27:11 +0000 (UTC) X-FDA: 81529816662.28.7B5A7EC Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf28.hostedemail.com (Postfix) with ESMTP id C65D4C0009 for <linux-mm@kvack.org>; Mon, 4 Dec 2023 17:27:09 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d2iSXqg7; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701710829; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=s41UoV2cG8vnTFsXoi3fzoh5S7YT2sqdp5SapWxg8Xy7XJa/vEaoRTzswzQ/Tc4+E8mD/r wm2l0SXmndmYYiw4BB8Oqiysy3IAa7Z40qzIHEqJsLbkcMNL6BSmWhFeLOVZVT3xvAY8Wa UWvq5shENsyexIP8CCVoPybXAqKjUH8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d2iSXqg7; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701710829; a=rsa-sha256; cv=none; b=CuxUJuD/79p14Mac+9Dvu7tf/09g0z0eV91ItR8Y5FIZ23/5edWD80DyS1UK8vLhoiHsTW JH/frLdgGuurYjkBoinjsuojgL0RCeJA1FAjKyZU/shxzwSF+Gg9ZbvhOmEiJcY2mXAX1n P99Z5PQnhCSITgDSLSza6WCROr7VUZw= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5d3cdd6f132so58980207b3.2 for <linux-mm@kvack.org>; Mon, 04 Dec 2023 09:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701710829; x=1702315629; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=d2iSXqg7AlUxl6eOt+Wz73G0wcVWwG0v8sw47AEM6w+OunkfXJLHVO59hv2iUWdz6i nKvv+NwpXkp2AvNcPZZMQJ81o60VDMOWxKlIPsHOzZW5V53DfFg5KOKJSlYVmUy0KCSk IIxMweNy2BRy2TuFmfdyIFZ/R7u3sgLmb0FATewUr3qgAlJtEy4q6xxHt1L7ze4hcVUc +bchlUxHMmeRVrRrhyX6Z+90YCzsIspINCeufP9zC6L6g0xbusWu1X08L3ZHuhDeROYI Dgz70/q0CPDvJTA/ihMgPP8Y9OwaVwgQQRCepw0khfrWuIF73peQmhdCdRC6VF7GQs8K N26g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701710829; x=1702315629; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=MKUJdUpKRv38uuilQmYT4tlgKChpj3cUXumFBXY0YVkkC2+lSZQwODAqGRtUVLIkaD b+R5c1cfqXxqV7gUFSd7qnkYUV9zrEESLWigJr4d7stA7IhLMKd9benoS2zwx1k8vxlt P/9VOr6OVSF4p8d69eUw3CAUdc+pZfjc6dN1PQ5nJmOR7uX5Mw8M2F0wzBiNm+iAj3CS fAfxUnEMB93uJeEBsx0zU3JpDNu51WxFFpJ4wkW7jPiH/3ehiIQmA+6nA1GmHdGUb3Tf obYJm9Awm5WdvBfa4Q8ULOLPSCmfssqwo2ke9I8rDJ1sVUGRXJQh4qcvOzOLj4FKMvJb azSA== X-Gm-Message-State: AOJu0Yw/g5HYrdlL25y6NIyi+r/g87lVV18YqaMiBlKIemFkVLAwjOWj JRnKRWJ4fZOFKV3rmiP2z72prGn2gCkh39rv X-Google-Smtp-Source: AGHT+IEhvePiHl3xyV55jaT6gG1N1cwFNsflp2+fj8EBDZAd96hh+3/YkVm099+dmC2eTTOXHiutCQyCzt5QJhnb X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:b61d:0:b0:5d3:84d4:eb35 with SMTP id u29-20020a81b61d000000b005d384d4eb35mr358241ywh.3.1701710828830; Mon, 04 Dec 2023 09:27:08 -0800 (PST) Date: Mon, 4 Dec 2023 17:26:45 +0000 In-Reply-To: <20231204172646.2541916-1-jthoughton@google.com> Mime-Version: 1.0 References: <20231204172646.2541916-1-jthoughton@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231204172646.2541916-2-jthoughton@google.com> Subject: [PATCH 1/2] arm64: hugetlb: Distinguish between hw and sw dirtiness in __cont_access_flags_changed From: James Houghton <jthoughton@google.com> To: Steve Capper <steve.capper@arm.com>, Will Deacon <will@kernel.org>, Andrew Morton <akpm@linux-foundation.org> Cc: Mike Kravetz <mike.kravetz@oracle.com>, Muchun Song <songmuchun@bytedance.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Ryan Roberts <ryan.roberts@arm.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton <jthoughton@google.com>, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: C65D4C0009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 57pj8ryc5ae3mq4gxadedj1zunk3er5a X-HE-Tag: 1701710829-218348 X-HE-Meta: U2FsdGVkX1/CAEHqr1J2rUGyTd6jxWw+f1xQQxjdwW2Oa8JDlsu1UEPUfJXMq0JIC7xVKaJxjDhGcItKYtFktVM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m//wCHFigku7OcYpwosJlMQOVR+pHQRmlmmRGxm0JSxZYy2uNwgjHK5GEO9J6IWlTh+JPHOHIOf4M2zh+/8y6DlMLKfg7pHgkYvooAPmNGYuc/L00aYPwxx32EvaSiV2m/NynuLHPqP89zimSwoXo4B3CZk1pUpI2177patbSihu3IeLOJPh8TUAPW6rUHnJaYQ8k1bGGXnt2L+mURHW4uBEx1iG8DhIUgkbMhhNT0+9rH9y0ZuChh0X/gjeO8gy9i7hDxiRNMfjZUZdZ9kKuwPfqhHc4rvVQRaJP0Sh7Tmc7ns/U7/Q4U8Ukx+8y5SWAtyL+LHzG7nmqY5iHIMKahr7wIumrunLK2BZ4KAsZHLpPj/iticsMWD21EkIdKwhqcmibO/w6P5GNPvl6XG2GRcPjY7Pgq5mgGwHKhNZbq1RvqGu6uWisuu0wO/vogXOUvd5OW3HELYzy4rFPENZUfoLcydpq016DQdOwwQrFxMWSE8Wqxvsa9+xGK21Xaj8Ml6M+PSXdhjrI9+FsFORWLAP5YRGZTQ5o51mjnh6rVXLz1bYbmN7S3z99sJuNfAeTs9rDjTiVwvGA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000269, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
arm64: hugetlb: Fix page fault loop for sw-dirty/hw-clean contiguous PTEs
|
expand
|
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f5aae342632c..87a9564976fa 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -437,7 +437,10 @@ static int __cont_access_flags_changed(pte_t *ptep, pte_t pte, int ncontig) for (i = 0; i < ncontig; i++) { pte_t orig_pte = ptep_get(ptep + i); - if (pte_dirty(pte) != pte_dirty(orig_pte)) + if (pte_sw_dirty(pte) != pte_sw_dirty(orig_pte)) + return 1; + + if (pte_hw_dirty(pte) != pte_hw_dirty(orig_pte)) return 1; if (pte_young(pte) != pte_young(orig_pte))
__cont_access_flags_changed was originally introduced to avoid making unnecessary changes to the PTEs. Consider the following case: all the PTEs in the contiguous group have PTE_DIRTY | PTE_RDONLY | PTE_WRITE, and we are running on a system without HAFDBS. When writing via these PTEs, we will get a page fault, and hugetlb_fault will (rightly) attempt to update the PTEs with PTE_DIRTY | PTE_WRITE, but, as both the original PTEs and the new PTEs are pte_dirty(), __cont_access_flags_changed prevents the pgprot update from occurring. To avoid the page fault loop that we get ourselves into, distinguish between hardware-dirty and software-dirty for this check. Non-contiguous PTEs aren't broken in the same way, as we will always write a new PTE unless the new PTE is exactly equal to the old one. Fixes: 031e6e6b4e12 ("arm64: hugetlb: Avoid unnecessary clearing in huge_ptep_set_access_flags") Signed-off-by: James Houghton <jthoughton@google.com> Cc: <stable@vger.kernel.org>