Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4449537rwe; Mon, 17 Apr 2023 12:53:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqRMXRKRT3JpjliY2l6NYJP52+wEmIUGuV3USXI4hE0xqjw4jg1KAfcoWSs13mTc+vDItc X-Received: by 2002:a05:6a20:7528:b0:ec:26ee:9eb5 with SMTP id r40-20020a056a20752800b000ec26ee9eb5mr13210290pzd.24.1681761208754; Mon, 17 Apr 2023 12:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681761208; cv=none; d=google.com; s=arc-20160816; b=EGK/GlEI+L8idSSINOv2xHxGnziPkzwR5h6Q7mnfzz7oK7g+GE6+gmoYypjDso8Xeu /ivw7LIwbcOt0y1q8UP4mBT+xk+oWdWGAnaoHBuqRnqzeklu8GCZaMfn88wz1WTW93fS L+QRDbzXWoesgk28UaOzMNkLYAXOE8Vc+gnQhHjyLOCGMR1hgbxoRWydgfWXgQPC5sGx rN3l5FZiW75s2lQpiGq/gJzjaeBGAurqiVhOOUh4szD3q7cixjYxPi+uTtkTDHo9Oenl yFcJGMXSEp1eDZ4n9NxspzlhH3hnCUr3H4/G/a7AfKwuwFn8tvoc4fQcds5N59OYji5k GxnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ys6bHj0kEYQG5dBpJYBFUjQoxCIC6tHrlD1Aj5lZyJw=; b=LLso4p9RhhbcF/AHxLhtSLgzgEpF3+/N4tsRF7tbXk4Ygk8fOeViV6Ft6uWHPmJwMR aop+Dc4ETOKmYTZWMU3UkhlF08iT2hMynzX5McYee9vvvUQKIzYZ0nlN3P/Z5iBM+d0G VQ2g2OOS3rMdXjdpq3SMk2z+bHkr8rba/DAbJ4uUqjjoclpKahdRPZReZeQcqUyqvrFt BW9rDh2EViofpKQv71P+YkwQOWMMGyEgDlOsaEEkRP8J9eMdWbnt40Azh0cDtZknEL7F 3hW9QIiAsSYQKw0nyKpSWCzLAaId2bUEcI4W8UIuVWHnMgmCWldx/cetZcbJCbS17aHT Zgmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SyaoJrta; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020aa79429000000b0063b1f577d29si11856890pfo.192.2023.04.17.12.53.17; Mon, 17 Apr 2023 12:53:28 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=SyaoJrta; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbjDQTm7 (ORCPT + 99 others); Mon, 17 Apr 2023 15:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbjDQTm5 (ORCPT ); Mon, 17 Apr 2023 15:42:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67F71D2 for ; Mon, 17 Apr 2023 12:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681760527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ys6bHj0kEYQG5dBpJYBFUjQoxCIC6tHrlD1Aj5lZyJw=; b=SyaoJrtamkTfPjcHI91k0Qrx4v0hANxrRY5SOu71ruIQJMLcBC1xzhg8elFDeBKKsnu7mm pkKaXACjqMeMtaj4wIZTTIKyFkmO/ZWsDHzlOCCbbyBC1zAPjmPndpUYfbD2cwbPnJ3Rgm DtosZ7RExVFNzOZnyM4eHFziYwF9gwU= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-MA0VtU-JPuicbji-kBiLVw-1; Mon, 17 Apr 2023 15:42:06 -0400 X-MC-Unique: MA0VtU-JPuicbji-kBiLVw-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-54fbf53aa09so4830307b3.1 for ; Mon, 17 Apr 2023 12:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681760526; x=1684352526; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ys6bHj0kEYQG5dBpJYBFUjQoxCIC6tHrlD1Aj5lZyJw=; b=NP0GY+0FyirYwVVE3oGsCI8F4MLzCtouCD/Y7XEiu6JTSHZ2BuAt65V/MOjI8tyWvO aEG03qfy0o3XCP6kwQvPzt2NI6FNbwQ5cCR5MlJ26F4kSimaUQwbf3Q5ZRWX8W7jaJtw CkuAfQ7TsuOnwiKqBTo5W+iIzJGIxn++nAvbOQJi1FkMbX5t9yvpyIqd5LvHZn1gNrds 9Mlrcfe/eKShYeU+x0y1VYSYCHmm9baBJxmtd5JlO1C6ES8HN/I4o41Zb0m/Zv77Ws9D vPKy1M2kI24xyfgRSyDhhaUGwzhPn4vwQe2Vdnwxy0juqYtMW0pWlQ4EJ6gKLJM1E1s5 n8Lg== X-Gm-Message-State: AAQBX9fmx31uG2lse4FEQgmOcE8OSK1Gvg+fwR2tz1yWRW++IXsM25y/ HnUcE4zm4D3AWC6N2ROzq8GIZ8YHXeP7ene635aKIkFe9KXSko96LTM2OQhijPskZW1g60ZDL1Y sfIgQCHzpWlR4et3oz7p8M8xF X-Received: by 2002:a25:f812:0:b0:b92:2ec4:468 with SMTP id u18-20020a25f812000000b00b922ec40468mr8387647ybd.2.1681760525799; Mon, 17 Apr 2023 12:42:05 -0700 (PDT) X-Received: by 2002:a25:f812:0:b0:b92:2ec4:468 with SMTP id u18-20020a25f812000000b00b922ec40468mr8387624ybd.2.1681760525481; Mon, 17 Apr 2023 12:42:05 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id a67-20020a254d46000000b00b8bfb4c4f1esm3139594ybb.62.2023.04.17.12.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 12:42:04 -0700 (PDT) Date: Mon, 17 Apr 2023 15:42:02 -0400 From: Peter Xu To: Muhammad Usama Anjum Cc: David Hildenbrand , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrei Vagin , Danylo Mocherniuk , Paul Gofman , Cyrill Gorcunov , Mike Rapoport , Nadav Amit , Alexander Viro , Shuah Khan , Christian Brauner , Yang Shi , Vlastimil Babka , "Liam R . Howlett" , Yun Zhou , Suren Baghdasaryan , Alex Sierra , Matthew Wilcox , Pasha Tatashin , Axel Rasmussen , "Gustavo A . R . Silva" , Dan Williams , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Greg KH , kernel@collabora.com Subject: Re: [PATCH v13 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs Message-ID: References: <20230417125630.1146906-1-usama.anjum@collabora.com> <20230417125630.1146906-3-usama.anjum@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230417125630.1146906-3-usama.anjum@collabora.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Muhammad, On Mon, Apr 17, 2023 at 05:56:27PM +0500, Muhammad Usama Anjum wrote: > +static int pagemap_scan_pmd_entry(pmd_t *pmd, unsigned long start, > + unsigned long end, struct mm_walk *walk) > +{ > + struct pagemap_scan_private *p = walk->private; > + struct vm_area_struct *vma = walk->vma; > + unsigned long addr = end; > + pte_t *pte, *orig_pte; > + spinlock_t *ptl; > + bool is_written; > + int ret = 0; > + > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + ptl = pmd_trans_huge_lock(pmd, vma); > + if (ptl) { > + unsigned long n_pages = (end - start)/PAGE_SIZE; > + > + if (p->max_pages && n_pages > p->max_pages - p->found_pages) > + n_pages = p->max_pages - p->found_pages; > + > + is_written = !is_pmd_uffd_wp(*pmd); > + > + /* > + * Break huge page into small pages if the WP operation need to > + * be performed is on a portion of the huge page. > + */ > + if (is_written && PM_SCAN_DO_UFFD_WP(p) && > + n_pages < HPAGE_SIZE/PAGE_SIZE) { > + spin_unlock(ptl); > + split_huge_pmd(vma, pmd, start); > + goto process_smaller_pages; > + } > + > + ret = pagemap_scan_output(is_written, vma->vm_file, > + pmd_present(*pmd), is_swap_pmd(*pmd), > + p, start, n_pages); > + > + if (ret >= 0 && is_written && PM_SCAN_DO_UFFD_WP(p)) > + make_uffd_wp_pmd(vma, addr, pmd); > + > + spin_unlock(ptl); > + return ret; > + } > +process_smaller_pages: > + if (pmd_trans_unstable(pmd)) > + return 0; > +#endif > + > + pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl); > + for (addr = start; addr < end && !ret; pte++, addr += PAGE_SIZE) { > + is_written = !is_pte_uffd_wp(*pte); > + > + ret = pagemap_scan_output(is_written, vma->vm_file, > + pte_present(*pte), is_swap_pte(*pte), > + p, addr, 1); > + > + if (ret >= 0 && is_written && PM_SCAN_DO_UFFD_WP(p)) > + make_uffd_wp_pte(vma, addr, pte); > + } > + pte_unmap_unlock(orig_pte, ptl); IIUC tlb flushes, mmu notifications are still missing here, am I right? Thanks, > + > + cond_resched(); > + return ret; > +} -- Peter Xu