From patchwork Fri Apr 14 14:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chih-En Lin X-Patchwork-Id: 13211640 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1173C77B72 for ; Fri, 14 Apr 2023 14:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbjDNO1p (ORCPT ); Fri, 14 Apr 2023 10:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjDNO1L (ORCPT ); Fri, 14 Apr 2023 10:27:11 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA40BB466; Fri, 14 Apr 2023 07:26:32 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id pm7-20020a17090b3c4700b00246f00dace2so10889278pjb.2; Fri, 14 Apr 2023 07:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681482390; x=1684074390; 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=rbLbXdRuHfxtXDKPQRm3+FT68gnEt5TFpjsogoRT0lI=; b=HmAKDMksf6xnRVcfcxIezwmEPoznukRB4mgVdijUHQ21YemDDShfTmL8ccYJJy/uIv m8wcVocb0Vu9eVxKqU1s7MpYGhcuKa+oShTZ+fEaDuq206zVo4U+a6BLfds/qNiJyf9P aBJBBXz5pGWdJwCV/ISvkd5f2lPY9+MmyenS3R3CLgKuxE1lM3D7qGDF37xFAjH6b+F4 3VsNve3Y7ot1RL+o7x7nuJ4ZPPVWRZ9yCgTv0NDTjoGu5zBmi13H0UBJOVTjJJqfyBjX eBme7l2CRwYd3A7kXwU5eY0/p3lxE6ieNay2Hkcq0BUNNIpDcn+prGiU5zYTEFJds9wk 5U3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681482390; x=1684074390; 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=rbLbXdRuHfxtXDKPQRm3+FT68gnEt5TFpjsogoRT0lI=; b=MG1A1b6BuApdHyK70zewH85v7y3usbnlluqUZo/wRglrBC6ImPTv9phRjx3khES7P1 4khJKGBKdAjyGQgTqLQprzNl9tvZ8cxfLs37QqYkXOBr/McDherszCPRNAa02Nm/UA2o VqwFq+syFhVY4bIi3xwMNm3cuJnu27HSVPq7vkKb5rOawvxFtUPF4GLDHtlpD0IUEk8y QjgOHYWsBZf+Wd7gBom8fdFzstsXESFWqNjUMGMHxuzsWSfYG2K8TaWLdWafA7uWC5Px Y85F0bDrPTXw25N7Y+fJP6cNCOKppBSEQ4mrTB0m7F5BQfSs/yciwi97dO3Vs3eJL3UQ qcXA== X-Gm-Message-State: AAQBX9fMNhgc9pYynaOUkGECM5Pm/mWbnJfjWZNE12Jw0xF0TYt0zpwU MM/y6PoU4VAFuNmItQ32Q9M= X-Google-Smtp-Source: AKy350aqLfuqbdu67mJ4nM0k7rzcjp896bC+PGdAfO2G4R7flBKcTTuNhdwRHh+IhJRQkBKzvLByHQ== X-Received: by 2002:a17:90a:2c05:b0:247:1e1e:57c0 with SMTP id m5-20020a17090a2c0500b002471e1e57c0mr5918775pjd.14.1681482390502; Fri, 14 Apr 2023 07:26:30 -0700 (PDT) Received: from strix-laptop.. (2001-b011-20e0-1499-8303-7502-d3d7-e13b.dynamic-ip6.hinet.net. [2001:b011:20e0:1499:8303:7502:d3d7:e13b]) by smtp.googlemail.com with ESMTPSA id h7-20020a17090ac38700b0022335f1dae2sm2952386pjt.22.2023.04.14.07.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:26:30 -0700 (PDT) From: Chih-En Lin To: Andrew Morton , Qi Zheng , David Hildenbrand , "Matthew Wilcox (Oracle)" , Christophe Leroy , John Hubbard , Nadav Amit , Barry Song , Pasha Tatashin Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Peter Zijlstra , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yu Zhao , Steven Barrett , Juergen Gross , Peter Xu , Kefeng Wang , Tong Tiangen , Christoph Hellwig , "Liam R. Howlett" , Yang Shi , Vlastimil Babka , Alex Sierra , Vincent Whitchurch , Anshuman Khandual , Li kunyu , Liu Shixin , Hugh Dickins , Minchan Kim , Joey Gouly , Chih-En Lin , Michal Hocko , Suren Baghdasaryan , "Zach O'Keefe" , Gautam Menghani , Catalin Marinas , Mark Brown , "Eric W. Biederman" , Andrei Vagin , Shakeel Butt , Daniel Bristot de Oliveira , "Jason A. Donenfeld" , Greg Kroah-Hartman , Alexey Gladkov , x86@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Dinglan Peng , Pedro Fonseca , Jim Huang , Huichun Feng Subject: [PATCH v5 14/17] fs/proc: Support COW PTE with clear_refs_write Date: Fri, 14 Apr 2023 22:23:38 +0800 Message-Id: <20230414142341.354556-15-shiyn.lin@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414142341.354556-1-shiyn.lin@gmail.com> References: <20230414142341.354556-1-shiyn.lin@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Before clearing the entry in COW-ed PTE, break COW PTE first. Signed-off-by: Chih-En Lin --- fs/proc/task_mmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6a96e1713fd5..c76b74029dfd 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1195,6 +1195,11 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (pmd_trans_unstable(pmd)) return 0; + /* Only break COW when we modify the soft-dirty bit. */ + if (cp->type == CLEAR_REFS_SOFT_DIRTY && + break_cow_pte(vma, pmd, addr)) + return 0; + pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); for (; addr != end; pte++, addr += PAGE_SIZE) { ptent = *pte;