Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1604105rdg; Sat, 12 Aug 2023 08:06:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHb3zgsCEXvhwKY08KYA1UBD7Gt1jPVBRqutjB+t5pUw1C0QuQYZuvCRi/zO8pbOQ29byM+ X-Received: by 2002:a17:902:a40a:b0:1b8:e41:f43f with SMTP id p10-20020a170902a40a00b001b80e41f43fmr5557753plq.27.1691852791213; Sat, 12 Aug 2023 08:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691852791; cv=none; d=google.com; s=arc-20160816; b=yf7MXFS1tKuRKtpW7nZP9d3yUBpzT7HdNGWsKtgn2MzbvctFmjdBibHWskYLtuATIT mP/5xT1AhdLggHNstVOkLrPPdSwZRVb8wvFvlD91ZVWw/RgDeuPZG9fV1TA5mjUHwLkb eiQfqonB+2p33uGErZ0y+uWHiDxndzRSwSFq32B+QFhDUQJqOH7BdN1/Li4qM1jRaVIT y4UlZq3XE83/Ow2068Mj9CoRkiEpgqLK4jNTkLAmmTfvvAAuDAzLdJghB39v2v/9R2gq wQi/b3ln7rp6evk+K1Wb9aPm+uJh20TSUt0KJntvuaQGJ1cQ+oOZY+QVPSRJ2R4I/wtk IUqQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=n4OBDHZhaecYk2HQNt9EqUoSLTkltaLUc4mc2oRO//Q=; fh=+IxPxAKfuyOQCtx4t8OBRPDeWP0JGhkhVR9LPsk1gnE=; b=ezhmrPSmB2vY8ZVknVwv+kWmhmtpXleaHAojA8jNZCNRO20M9v5Yy2owHAexB4JJrW 4xFA+i2Y2ybCsDVbN4hQqherRTzs6pRxMBZ0YTkhpi330Hbx/4Vq/rN+xBsmElzDQe8B 8OObflI/kkDE3GOemEAiHsIYMXM+jGIAKDnHu5f0yiUmk6J4eTKcZbFYHIAQm0EygIYP 7vDdrUFaUrsRVbbXXKkCt3RBmN9niWScgPldaorti2cFzEMrvTeZPEc/erwEIhcQQ7hd n9ZnhI5xYPOgYuEWLN8oDhOu0GDw1nxYp2+O5TJ4qnVPqMV1YRtKpYXkyhTfQHrOMNUy WNeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=c3QN0Pdb; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a170902680d00b001bb7b3e607dsi4883485plk.21.2023.08.12.08.06.18; Sat, 12 Aug 2023 08:06:31 -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=@rere.qmqm.pl header.s=1 header.b=c3QN0Pdb; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236755AbjHLOWS (ORCPT + 99 others); Sat, 12 Aug 2023 10:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234551AbjHLOWQ (ORCPT ); Sat, 12 Aug 2023 10:22:16 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BF54171F; Sat, 12 Aug 2023 07:22:18 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4RNNCR1K35z8L; Sat, 12 Aug 2023 16:22:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1691850136; bh=u5bq7pd5Cv90/Zbgy2FhjyRSbq0SeJ3nBFKvllWi1eg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c3QN0PdbGboHQRbBeobFKVXGXglpVS0Mrl0gqCrK49+VoIjGt/OyVtf9lbfoSz5W7 oXedUXsCMS59O0kX2vamz4MNt1flWx1AorUMh2Cc+gp7Gn/pbvaHsHb/n4JSDv1pfg v1By/PS1eu61cqPVOE3EtQ53iHf7pELje3zmG5My2sG/sjaL8GmlADrKRr0ANFf+JA hij/Eo1vOvA/gzdJR9QUOLskfTfw6WD77N1V+1DgRzPpsy3u/BDqGtlLsXT/tnRPHC MkPyYl5LxLUVuFu/NF/42rz04gFxscyMb6I63fmubnrp5lGQ4szPSjD2yxXnivZ69i AvvZCuk7olxxg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Sat, 12 Aug 2023 16:22:09 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Muhammad Usama Anjum Cc: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= , Peter Xu , David Hildenbrand , Andrew Morton , 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 v28 2/6] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs Message-ID: References: <20230809061603.1969154-1-usama.anjum@collabora.com> <20230809061603.1969154-3-usama.anjum@collabora.com> <97de19a3-bba2-9260-7741-cd5b6f4581e9@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 Fri, Aug 11, 2023 at 08:30:16PM +0500, Muhammad Usama Anjum wrote: > On 8/11/23 6:32 PM, Michał Mirosław wrote: > > On Fri, Aug 11, 2023 at 05:02:44PM +0500, Muhammad Usama Anjum wrote: > >> Now we are walking the entire range walk_page_range(). We don't break loop > >> when we get -ENOSPC as this error may only mean that the temporary buffer > >> is full. So we need check if max pages have been found or output buffer is > >> full or ret is 0 or any other error. When p.arg.vec_len = 1 is end > >> condition as the last entry is in cur. As we have walked over the entire > >> range, cur must be full after which the walk returned. > >> > >> So current condition is necessary. I've double checked it. I'll change it > >> to `p.arg.vec_len == 1`. > > If we have walked the whole range, then the loop will end anyway due to > > `walk_start < walk_end` not held in the `for()`'s condition. > Sorry, for not explaining to-the-point. > Why would we walk the entire range when we should recognize that the output > buffer is full and break the loop? > > I've test cases written for this case. If I remove `p.arg.vec_len == 1` > check, there is infinite loop for walking. So we are doing correct thing here. It seems there is a bug somewhere then. I'll take a look at v29. > > [...] > >>>> +/* > >>>> + * struct pm_scan_arg - Pagemap ioctl argument > >>>> + * @size: Size of the structure > >>>> + * @flags: Flags for the IOCTL > >>>> + * @start: Starting address of the region > >>>> + * @end: Ending address of the region > >>>> + * @walk_end Address where the scan stopped (written by kernel). > >>>> + * walk_end == end informs that the scan completed on entire range. > >>> > >>> Can we ensure this holds also for the tagged pointers? > >> No, we cannot. > > So this need explanation in the comment here. (Though I'd still like to > > know how the address tags are supposed to be used from someone that > > knows them.) > I've looked at some documentations (presentations/talks) about tags. Tags > is more like userspace feature. Kernel should just ignore them for our use > case. I'll add comment. Kernel does ignore them when reading, but what about returning a tagged pointer? How that should work? In case of `walk_end` we can safely copy the tag from `end` or `start` when we return exactly on of those. But what about other addresses? When fed back as `start` any tag will work, so the question is only what to do with pointers in the middle? We can clear those of course - this should be mentioned in the doc - so userspace always gets a predictable value (note: 'predictable' does not require treating `start` and `end` the same way as addresses between them, just that what happens is well defined). (I think making `walk_end` == `end` work regardless of pointer tagging will make userspace happier, but I guess doc will also make it workable. And I'm repeating myself. ;-) Best Regards Michał Mirosław