Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3676893rwj; Mon, 19 Dec 2022 23:48:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf7E4o72TNHXj4fjfRxAUHXy8ZcEa9G9wHhxkLk98cqRK06pVGSn++yXC2VM8ZoMGNbUwyW4 X-Received: by 2002:a17:90a:d347:b0:219:9676:fef5 with SMTP id i7-20020a17090ad34700b002199676fef5mr47197094pjx.12.1671522485314; Mon, 19 Dec 2022 23:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671522485; cv=none; d=google.com; s=arc-20160816; b=BGWpWzs91b9OYkhKLxksRRR7QjsdM+b17VPik3zA0MYDjrFbN3NY+xvtkFZh50sYZZ AOPx4/HfWbz4MRObcAyqT8oWtgSGmNGBVjMsw2hY5Q+1WPZn5rOYhhLBMmCIkKXrFdWn lkSi3q0t0Oaf5t4JFyS2PJ7GpNzz8/w2BKblDT3bSCNjXhlnVrnJYcORDxkorJ5xI5Uf Pf5ur9ZFzjGF4L+YR5IHtytaKSxBJ+m8D+gRNF8m1O3p6qLW7KqSccAsHg7IHBjmiq4o 89J4jbVJU0rDsdOFVWMVSIlCOSS0ci0aWG664gwgHbRrUw3EQQUEJsOCqQ6tMprHBNMn 3jTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SyroKMXkbrC7KLBuW9kdtHrj2LCvgbvHbaCl4XJKm0w=; b=esSTVmxLGGYFZDTHxk2504UnzGRIzB1Y5TQSM3OrIgoc5MqQcpQIICzxqVS28d0/8Y plzNvv0eRhaK0rWj72gSc1gCIjIq/4zBAHXmhNpXuTEFgLd6HQTZy6KvnCgVnU+7On6g YejUZtp8mAFzO+kCPayQFCYvliNXEZw1Oj508bObFlPxA04W3syebL6OSU1nBtLJmPQp 09f5BjLr+fUp/SjqWEwsrsPo9aCXslJwfoWhLIOejMNXSNTK7qoRp+WVfGGEsz60v4Nd 00iqJwSXMIcFouUKp5TIYfBgrImzdIPdPtt0QVSAKQSs6JnEeblZA441ZHU9kKYYosri PCrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RzWa85xp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a17090aea0400b00202c8fa5c54si18816848pjy.95.2022.12.19.23.47.56; Mon, 19 Dec 2022 23:48:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RzWa85xp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233654AbiLTH2H (ORCPT + 70 others); Tue, 20 Dec 2022 02:28:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbiLTH1i (ORCPT ); Tue, 20 Dec 2022 02:27:38 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CD217AA0 for ; Mon, 19 Dec 2022 23:26:47 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so11234401pjj.4 for ; Mon, 19 Dec 2022 23:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=SyroKMXkbrC7KLBuW9kdtHrj2LCvgbvHbaCl4XJKm0w=; b=RzWa85xp16ahKT8BYmKLizeFGJjcYh214M4gWXHr/BTGRafxhKKmAVlwNLT+ZEN/GA 1qDOToWo/wBMgTwbWnQ09xZqyazrhaVn48i6iInQH8gYcAdY3XYwCCebYfMurD7oW4fC vqWTNzfPplWVDkB4u7LVVi1xTyT30BJ3wEB2Vnn1TYtRnCWoebepvUJiJc41xQcDYVYM aPo9CDa9/5/L7J2cSCBw0wUtntyh2UxiQczZ0ZwdrZfgWPmfW1T0uX8u/AVR+Q/end4m tjci9bFINZ3mAj6dvfIpyxVwESPZNUSkFxZpnhPHOoVBNWsVbqJiMRMOBUi24P5iB0Qn s+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=SyroKMXkbrC7KLBuW9kdtHrj2LCvgbvHbaCl4XJKm0w=; b=vks1Z9OFLwA1allOv83OjnfV4E5ZktxWGhJsoDXqBTJoRR13nfoMj1bdt3CaVsEnPS 32itTdYO0zcRyMh9jJpOTlLVyPb4huV7Pcm3H/rDso824AhmkPtyT4hfKqgF8CyxeXVu 2SsSrL3Jb0YxnmyMhzzrxU4Xda++RfoESvuVRsaP/E8l8A6rauD/QNbJ2Yh8S6qUDP6E fIvL2I186M5AXICrxj4G1ipd9siuzEPndF+dVCFYyEy+wT+hH0iKo+QOE0ilEcXTSacm MGFKR4Nl9NbHXaTW4hyVfb9sUyG93EgW6dfGUixvjeICRNmiq9+zu71EN8IMxJrqvrJF X1og== X-Gm-Message-State: AFqh2kpAxViKZMm9qxZ/WZuPM5si9k2x1obuTva5Zr/QyUOIFXUn/lVz fz3QESrESpptHpdPlH4lh64= X-Received: by 2002:a05:6a21:3a43:b0:b0:275d:3036 with SMTP id zu3-20020a056a213a4300b000b0275d3036mr11490037pzb.24.1671521207015; Mon, 19 Dec 2022 23:26:47 -0800 (PST) Received: from archlinux.localdomain ([140.121.198.213]) by smtp.googlemail.com with ESMTPSA id q15-20020aa7982f000000b00576f9773c80sm7865544pfl.206.2022.12.19.23.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 23:26:46 -0800 (PST) From: Chih-En Lin To: Andrew Morton , Qi Zheng , David Hildenbrand , Matthew Wilcox , Christophe Leroy , John Hubbard , Nadav Amit Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Steven Rostedt , Masami Hiramatsu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Yang Shi , Peter Xu , Zach O'Keefe , "Liam R . Howlett" , Alex Sierra , Xianting Tian , Colin Cross , Suren Baghdasaryan , Barry Song , Pasha Tatashin , Suleiman Souhlal , Brian Geffon , Yu Zhao , Tong Tiangen , Liu Shixin , Li kunyu , Anshuman Khandual , Vlastimil Babka , Hugh Dickins , Minchan Kim , Miaohe Lin , Gautam Menghani , Catalin Marinas , Mark Brown , Will Deacon , "Eric W . Biederman" , Thomas Gleixner , Sebastian Andrzej Siewior , Andy Lutomirski , Fenghua Yu , Barret Rhoden , Davidlohr Bueso , "Jason A . Donenfeld" , Dinglan Peng , Pedro Fonseca , Jim Huang , Huichun Feng , Chih-En Lin Subject: [PATCH v3 12/14] fs/proc: Support COW PTE with clear_refs_write Date: Tue, 20 Dec 2022 15:27:41 +0800 Message-Id: <20221220072743.3039060-13-shiyn.lin@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221220072743.3039060-1-shiyn.lin@gmail.com> References: <20221220072743.3039060-1-shiyn.lin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 8a74cdcc9af00..7d34b036c1b96 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1190,6 +1190,9 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (pmd_trans_unstable(pmd)) return 0; + if (break_cow_pte(vma, pmd, addr) < 0) + return 0; + pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); for (; addr != end; pte++, addr += PAGE_SIZE) { ptent = *pte; -- 2.37.3