Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7298781rwl; Mon, 9 Jan 2023 21:53:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvd6bQomiVBvFG3sfpyIPMFtYpFkWfPbkhqUCvrVdu3s1hFtCzymL5Kfy+O3ltimAdJAlq9 X-Received: by 2002:a05:6402:448f:b0:498:1f8:5378 with SMTP id er15-20020a056402448f00b0049801f85378mr9811458edb.16.1673329998118; Mon, 09 Jan 2023 21:53:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673329998; cv=none; d=google.com; s=arc-20160816; b=T91ZXl2CJBZ1HNIPFmdj27NG3N1cSE7ILjP0AUhI75RxjkGeA0iFFB7YwbwC4YcHBH yo5OUM/DP95ahHdd4HWCZCxByoOX22HDqgdmgON6cL0oGFGjmeUT69QpZqd0Xdn5zx7J 2h70qoPcDuZokrM7MOnG6s07+QtRWbwCoDpi5ZePA49t8SO7Pg70xc93S4g1G0qWT8um J5ezadyYVPeUZdRlrpdocvitiQRu2UX4mtg5Xp17nCM2QOpucG50dezOJs3cm0MltAbe /X4AnAuusT83EVr4oDEuFFc6fXthBdlFlVjjd1gkhNZFWJIbg/c4mLoqiyeZ2GkTonR7 8ATw== 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=a38ihKpZLqr6+buDZfowSJeglGta7Uu19tFOfigkSkQ=; b=nWod3PrC/vW09jmNXTMp7T4pB3GFzRaZAelHCKRLvNu2LR3Qn4CtlMNDiGao64k8If ZL6w3ed9G++BhLFjH2bTrFC4LK/q2SiVJiS81gez6mV5KhkLT7pePp9s3PrgGdyxdRX3 oROoWquENjMOhwIz4a47tCDJLiSqMs5VGcde597mWVi6RHW9dn6WeklgMzaXfkGe6gUQ /WQaNL+/rrSZGSOhtbjgol9AAQIVaF35kCTgU9qGTzGNDaN23HFeq05YMC4ZRTckSZGc hEADvPRRrurQ6iDxYEbNwJUfUWO4krHmtjQXZJpqno/WIjC1bSlnke3kAwq6h4vm6ukd dm/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="JpkC/d8F"; 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 h17-20020a05640250d100b0048f40b72e38si13023933edb.494.2023.01.09.21.53.02; Mon, 09 Jan 2023 21:53:18 -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="JpkC/d8F"; 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 S230097AbjAJFuY (ORCPT + 53 others); Tue, 10 Jan 2023 00:50:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbjAJFtc (ORCPT ); Tue, 10 Jan 2023 00:49:32 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300A038B2; Mon, 9 Jan 2023 21:49:30 -0800 (PST) Received: from [192.168.10.12] (unknown [39.45.186.163]) (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 225DA660230B; Tue, 10 Jan 2023 05:49:24 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1673329768; bh=IzktKiuA2C+7fFsNxOT5xp2wBaUGwyAnVvBi3Idir3E=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=JpkC/d8FVY+F4TtOcy4rj+hatadaGiVeh4gQRDbUXVPWKmVHn22jbsIquJ8kYQEUn bNWgZ0EijaKY2vMy4dcQdMQB/VzUd7do14SXu2oV3RTEnePYwt0wwePoOeZC1233C4 duOmeLsaMUo56TjPeTNtsY3VvxR7e0o3uAuEF57c4VmAx321s0x6AjPBJHx1w0z9+V 62gvy1zeYf3zE/XxpUheETJ/lCM4VUlP2rckcJ603iC6c3j6AvbLuaVnGjXtN6RCKe xHctrMfsbXkg6rHmj9a9lg83R8iwhfpYUJBwMT0EYsvOQZvc9SIu3NO7SvK19p6DBS n98N+vk+ecZkQ== Message-ID: <8a0ebe48-c9fd-b030-71bd-4a806c6d5f29@collabora.com> Date: Tue, 10 Jan 2023 10:49:20 +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 , Alexander Viro , Eric Biederman , Kees Cook , Andrew Morton , Steven Rostedt , Masami Hiramatsu , kernel@collabora.com, peterx@redhat.com, david@redhat.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] mm: implement granular soft-dirty vma support To: Cyrill Gorcunov References: <20221220162606.1595355-1-usama.anjum@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=-2.1 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 1/10/23 3:18 AM, Cyrill Gorcunov wrote: > On Tue, Dec 20, 2022 at 09:26:05PM +0500, Muhammad Usama Anjum wrote: > ... >> >> +static inline int nsdr_adjust_new_first(struct vm_area_struct *new, struct vm_area_struct *vma) >> +{ >> + struct non_sd_reg *r, *r_tmp, *reg; >> + unsigned long mid = vma->vm_start; >> + >> + list_for_each_entry_safe(r, r_tmp, &vma->non_sd_reg, nsdr_head) { >> + if (r->start < mid && r->end > mid) { >> + reg = kmalloc(sizeof(struct non_sd_reg), GFP_KERNEL); >> + if (!reg) >> + return -ENOMEM; >> + reg->start = r->start; >> + reg->end = mid; >> + list_add_tail(®->nsdr_head, &new->non_sd_reg); >> + >> + r->start = mid; >> + } else if (r->end <= mid) { >> + list_move_tail(&r->nsdr_head, &new->non_sd_reg); >> + } >> + } >> + return 0; >> +} > > Hi Muhhamad, really sorry for delay. Please enlighten me here if I get your No problem. > idea right -- every new VMA merge might create a new non_sd_seg entry, right? Every new VMA only has the non_sd_reg list initialized with no entries as the whole VMA is soft-dirty at creation time. We add entries in this list when the soft-dirty is cleared over the entire or the part of the VMA. Once soft_dirty has been cleared, there might be entries in the non_sd_reg lists of both VMAs which will be maintained properly if VMAs are split/merged or freed if removed. At this time, the soft-dirty can only be cleared over the entire process and hence over entire VMAs. So this list will have only one entry even if VMAs are merged until VMAs are split. > And this operation will be applied again and again until vma get freed. IOW > we gonna have a chain of non_sd_reg which will be hanging around until VMA > get freed, right? Correct. I've posted the next version of PAGEMAP_SCAN ioctl [1] where soft-dirty support has been replaced with UFFD WP async. If that goes in, soft-dirty support can be left alone as people don't seem receptive of the idea that the soft-dirty support should be corrected. UFFD WP async is better as it is PTE based. Please review it. [1] https://lore.kernel.org/all/20230109064519.3555250-1-usama.anjum@collabora.com -- BR, Muhammad Usama Anjum