Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5351243rwj; Wed, 21 Dec 2022 01:10:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXt8zBHorMQpoI6+39npF0sS9nVPrEtmI7fXLOV5rZjpzePH61CUUBYwB/x7OmnqCqoqrDAm X-Received: by 2002:a17:90b:4f4e:b0:219:89c3:2847 with SMTP id pj14-20020a17090b4f4e00b0021989c32847mr1260841pjb.44.1671613842015; Wed, 21 Dec 2022 01:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671613842; cv=none; d=google.com; s=arc-20160816; b=yiyhQY/rHmDp7qF6+hBuymCy7wWx4fcC8vEeg7DnYqrxZ5pzTyHIbXT4TErMdtfmGZ rGRelnBRdGMUqaFDbkdoxRdTh0k3iS1/+oxE4B7uHRFL5dVP81qqFjnVVozXxYyTVrY/ FYFk2ax1JcTn54uzQUDZFbonk3DuIm5SQd54CItbmyhFoCHXWIR09LjYSYqsHu8Nn1kg CMWP8R86rOWc+bvDuek+NsrVu/ZFBUgpzKxi39Gadw/0pF8EpBroHs27jyF3L7Hf8NVG DcCs07AZTZIPcSVEtuRvIXS6G6GN5Hi95tmT7q7JhL0iE0Mkthv29aOBS8hfTCitMaB/ BwDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=RWNEfjkcfEoeaWh2P80GUL77uXRtlPzX03N1jm4guq4=; b=ZUFZNwaXJKChZmtJpIq850JEQj7blJrKeS4dRk2iRTOJ+YbprecJPed35/ZQPYtV8a GMq7eG5DJaqmeg7L0SM7jaFJvXlrshc+BNxrAWMD0aRHtDdgC2P7rCsa97YGATy8x7bW C3+MrYUY32UOz++Fn2sY7e07Jn1U4l6+YAmaiZNhHtJsEQE+Bdb+OynWLOy7eP8om5iT wDYMj9GSLKQoo1O4ATXHV+Db1SLG5dmLexmLJV1OL64oWO1CGaOxSMzMQcfaemmTYtbN eWPUcNCyHrt9XR86lsbW04lCCMTtFy2rTlir+S5iiiFmLSsmJGaw0Vqrt14sVOdLVbV3 cGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=L61GocnZ; 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=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a17090ad51200b00213587b200esi1151835pju.189.2022.12.21.01.10.33; Wed, 21 Dec 2022 01:10:41 -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=@collabora.com header.s=mail header.b=L61GocnZ; 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=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232267AbiLUITV (ORCPT + 69 others); Wed, 21 Dec 2022 03:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbiLUISm (ORCPT ); Wed, 21 Dec 2022 03:18:42 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD12721814 for ; Wed, 21 Dec 2022 00:17:56 -0800 (PST) Received: from [192.168.10.12] (unknown [39.45.25.143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8AA736602CB6; Wed, 21 Dec 2022 08:17:52 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671610675; bh=9v9PWqa/qTx5cLrzTGi9/aiXNRHSQhPIhrxa12rDPXI=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=L61GocnZyLdobxoaWkciTAuhJH5ImCZENucuu+fNdyuyCe+eiW+4PQcoGIyv3iZCc 3yiI6L8GEp1oau1i88ADFY0KeZLFuwePQYuysPcuQUnFpSIV9AOImhTrHkobJup9G2 tRyvJygfN6aviuv4qKdoaCcp27SNBwOghUcqX2H64Be20PJ61paGkfClWr9/P+G0A5 jrKF1NQGaV5CvJVXja0srpmzVof5IES0DQpv75d7CFIqjqANane+70rb2czQigxT50 F+GeE59qLaABLWMjYa6lYBCq6CRFbvDxWVszsmXu2kRh0EcxUvDJFAFtOQxI7o90xJ jitCL7owd04BQ== Message-ID: <0d0e370c-04bd-aca4-ecb9-e50c06022183@collabora.com> Date: Wed, 21 Dec 2022 13:17:47 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Cc: Muhammad Usama Anjum , David Hildenbrand , Cyrill Gorcunov , Andrew Morton , Paul Gofman , Nadav Amit , Andrea Arcangeli , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel@collabora.com Subject: Re: [PATCH v4 1/3] mm/mprotect: Fix soft-dirty check in can_change_pte_writable() To: Peter Xu References: <20220725142048.30450-1-peterx@redhat.com> <20220725142048.30450-2-peterx@redhat.com> <0a3e3397-6ff3-1203-52cb-49636ef38247@collabora.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On 12/21/22 12:02 AM, Peter Xu wrote: > On Tue, Dec 20, 2022 at 11:15:00PM +0500, Muhammad Usama Anjum wrote: >> Hi Peter, > > Hi, Muhammad, > > [...] > >> Nothing has changed for the userspace. But when the default soft-dirty >> feature always updates the soft-dirty flag in the PTEs regardless of >> VM_SOFTDIRTY is set or not > > But it was not? I don't see why the pte flags must be considered at all if > VM_SOFTDIRTY is set in existing code base, or before this patch. I completely agree that setting pte flags isn't needed if VM_SOFTDIRTY is set. It is wasted effort. Before this patch, the effort was being wasted in the default part of the feature and in the other related components as well. After this patch, the effort is being wasted only in the default part of the feature and other related components have stopped doing this wasted effort which is a good thing. But now there is discrepancy that one part of code keeps on tracking pte while other has moved on/improved. > >> why does other components of the mm stop caring for soft-dirty flag in >> the PTE when VM_SOFTDIRTY is set? >> >>> >>> Your approach introduced PAGEMAP_NO_REUSED_REGIONS but that special >>> information is not remembered in vma, IIUC that's why you find things >>> messed up. Fundamentally, it's because you're trying to reuse soft-dirty >>> design but it's not completely soft-dirty anymore. >> Correct, that's why I'm trying to find a way to correct the soft-dirty >> support instead of using anything else. We should try and correct it. I've >> sent a RFC to track the soft-dirty flags for sub regions in the VMA. > > Note that I'm not against the change if that's servicing the purpose of the > enhancement you're proposing. But again I wouldn't use "correct" as the > word here because I still didn't see anything wrong with the old code. > > so IMHO the extra complexity on handling VM_SOFTDIRTY (even if to drop it > and replace with other structures to maintain ranged soft-dirty) needs to > be justified along with the feature introduced, not be justified as a fix. The question of tracking re-used regions should be answered by the original developers of the feature. I've been trying to get comments from them. But I've not got any. Maybe some conference talk can work where the maintainers/developers are present? Or I'll summarize the whole problem and ask Andrew directly. > > Thanks, > -- BR, Muhammad Usama Anjum