From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BE16C61DA4 for ; Fri, 24 Feb 2023 02:20:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE4FF6B0074; Thu, 23 Feb 2023 21:20:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C94FA6B0075; Thu, 23 Feb 2023 21:20:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5C3B6B0078; Thu, 23 Feb 2023 21:20:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A70E66B0074 for ; Thu, 23 Feb 2023 21:20:48 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 786821411DA for ; Fri, 24 Feb 2023 02:20:48 +0000 (UTC) X-FDA: 80500582176.20.A89F919 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by imf15.hostedemail.com (Postfix) with ESMTP id C060BA0006 for ; Fri, 24 Feb 2023 02:20:46 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ql4RUo5L; spf=pass (imf15.hostedemail.com: domain of avagin@gmail.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=avagin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677205246; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f01DwiBCCoSA8b356xeySu4YsZ3rzS92CP2vOVZhAWg=; b=Llg1U1ulFNq4GNtHZc9tdCtm+Rae2so6+rcobd5/zVsPq8OaegzGu6E0rLk4qivPap+MQe F0UGyhV+KGJZ0az74yoYsm1FDkyQSNXn+CKhV5/2JRrOHcCjblJaFXmgFjfUFw4IyzNqNX zzAmjYO1e66ypCo+G74puJf5J9QWMPs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ql4RUo5L; spf=pass (imf15.hostedemail.com: domain of avagin@gmail.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=avagin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677205246; a=rsa-sha256; cv=none; b=WCoZJfThQTbeLIpTJrbwVOGQLizGgxjKjSRUw6Mr5+ANuR4mqnbjBMAdcuddW3aW4k/0d8 OvhND3laXJa0SOpur9TMoQusM0LnEaTVynwj11FqTqvidiYpKSZb9IQkmsTtU813yqn8RB tefTDpdS5djUvgib1m/jVDlzYqhnnVo= Received: by mail-vs1-f47.google.com with SMTP id f31so19153662vsv.1 for ; Thu, 23 Feb 2023 18:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=f01DwiBCCoSA8b356xeySu4YsZ3rzS92CP2vOVZhAWg=; b=ql4RUo5LeGLa0GhN/7edy7N8eSQlsbke1N6qiltaZfQBUJuX/AwYqZ/Vm5kTVz39Xi ovseMGfGAqmFEuv1nHiRRbrhmddHrgZtohSszSQ+R8Z5KG/UR9Fjlqr9bDqiPB4V51Sq XcaVkvqD6lv8VpLPsDCfqIkUq6ZmB80JlW4ADCWbvnUxADl/iVBuDDmb/3hO7sUbQMeW z86bCviapNBo0b6mQpGtxmnJLqh0SbtiKuGganjZ5oW91qSLHPmweTnvFoitm7ucJqqF Vzw7iNvEi+jeCTRrNH+9CSh62O+2m7oaxGJ8zXm/TzAc8SZqEWL7owEjqkPh70bx2cX7 9kVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f01DwiBCCoSA8b356xeySu4YsZ3rzS92CP2vOVZhAWg=; b=GfAPPchJAR86q0uSe2AhpByMNnGCEQZm/tmls4JPoW4bFDxA7cIOc0yr5revxS89xM NAQDhpKBdIgtao+5QMDDRqJITF/MgYuqTZmXM8Xvv6XASYYjz4wTzCo8SYabVtGtjpKP iWlRUULVgDzepxOtFqQOVFu8+Res/khY8wCEtmM/z9lQrFi9w4ijMQKCTNSy472DRAaf 7d+eSs//9Kd3gEDOqWJpq7VAm+6r1/V6y57itegUdyJUZB43PfyKP5JV9pLur7chCn5O 1MZtYGYy/m+yqXQWQgogT0b5fT3vj6GSYfY7MU4hi5T8xu0Ybmj9LBqFrggPBCD+FyDQ 1WjQ== X-Gm-Message-State: AO0yUKVjxHNsySuDMllbcWEaSSmEwmLShsK8rVy0TrMXoCNW5astfMEJ PFSwOJz1fgpR6UV5uXwawNYRmddGOv1SNK1fqxg= X-Google-Smtp-Source: AK7set8GaFZs9grTBPV2TtGqHKOwcBoSfP0H2qOWvJ/sb72x2A3bDmtOsjArb1eEis7Bc9lNaMYPNjkC9qJrqfiPLyc= X-Received: by 2002:ab0:551a:0:b0:68e:2ed3:92eb with SMTP id t26-20020ab0551a000000b0068e2ed392ebmr3300972uaa.1.1677205245675; Thu, 23 Feb 2023 18:20:45 -0800 (PST) MIME-Version: 1.0 References: <20230202112915.867409-1-usama.anjum@collabora.com> <20230202112915.867409-4-usama.anjum@collabora.com> <36ddfd75-5c58-197b-16c9-9f819099ea6d@collabora.com> In-Reply-To: From: Andrei Vagin Date: Thu, 23 Feb 2023 18:20:29 -0800 Message-ID: Subject: Re: [PATCH v10 3/6] fs/proc/task_mmu: Implement IOCTL to get and/or the clear info about PTEs To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Muhammad Usama Anjum , Mike Rapoport , Nadav Amit , David Hildenbrand , Andrew Morton , Paul Gofman , Cyrill Gorcunov , Alexander Viro , Shuah Khan , Christian Brauner , Yang Shi , Vlastimil Babka , "Liam R . Howlett" , Yun Zhou , Suren Baghdasaryan , Alex Sierra , Peter Xu , 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, Danylo Mocherniuk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: 8hhd93f1raqo9sec67mewp1g5i3t41sz X-Rspam-User: X-Rspamd-Queue-Id: C060BA0006 X-Rspamd-Server: rspam06 X-HE-Tag: 1677205246-690021 X-HE-Meta: U2FsdGVkX18GuosAhb2+apMtEJLarHjPlGYfym3UZeSuIsJMXKS4XstWDGquM7cXQ3zKsyhgTdAYr6eA//sESqFoB/igyVJ/crl5yi5e3EuqLLLu2y78YGLOqAmpnAaS2mAmgsE1owpsOa/Vyf0RRUgBjcn1wnkzZ8tyfc89BMDAjfAEyZzjs9Agkr80dAyuWwXOXhSNhOulMgRkYHOwr13aZre97hQpBZodwwqObQ/10M1ap9lhnj39vBiRp91/eJq8y2yepngUl+xTxIDtmAaCly5r2fXI2W01/t3ctCKdplJUyDi+kJ4KP6/+bfn2+f2WiXXEQRNdeMzL/cx/C/+0VuRWa5Jip9vwtGwmDv6VYZm64ezcAG+Vndw4FeAfu0WIt8WXHY6dDAHM/O8g/gR/i7I9HuZlMFjAg5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WvR7VxeGky4qS6S4AGJN12h1CcziD80Wbs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 21, 2023 at 4:42=E2=80=AFAM Micha=C5=82 Miros=C5=82aw wrote: > > On Tue, 21 Feb 2023 at 11:28, Muhammad Usama Anjum > wrote: > > > > Hi Micha=C5=82, > > > > Thank you so much for comment! > > > > On 2/17/23 8:18=E2=80=AFPM, Micha=C5=82 Miros=C5=82aw wrote: > [...] > > > For the page-selection mechanism, currently required_mask and > > > excluded_mask have conflicting > > They are opposite of each other: > > All the set bits in required_mask must be set for the page to be select= ed. > > All the set bits in excluded_mask must _not_ be set for the page to be > > selected. > > > > > responsibilities. I suggest to rework that to: > > > 1. negated_flags: page flags which are to be negated before applying > > > the page selection using following masks; > > Sorry I'm unable to understand the negation (which is XOR?). Lets look = at > > the truth table: > > Page Flag negated_flags > > 0 0 0 > > 0 1 1 > > 1 0 1 > > 1 1 0 > > > > If a page flag is 0 and negated_flag is 1, the result would be 1 which = has > > changed the page flag. It isn't making sense to me. Why the page flag b= it > > is being fliped? > > > > When Anrdei had proposed these masks, they seemed like a fancy way of > > filtering inside kernel and it was straight forward to understand. Thes= e > > masks would help his use cases for CRIU. So I'd included it. Please can= you > > elaborate what is the purpose of negation? > > The XOR is a way to invert the tested value of a flag (from positive > to negative and the other way) without having the API with invalid > values (with required_flags and excluded_flags you need to define a > rule about what happens if a flag is present in both of the masks - > either prioritise one mask over the other or reject the call). > (Note: the XOR is applied only to the value of the flags for the > purpose of testing page-selection criteria.) Micha=C5=82, Your API isn't much different from the current one, but it requires a bit more brain activity for understanding. The current set of masks can be easy translated to the new one: negated_flags =3D excluded_flags required_flags_new =3D excluded_flags | required_flags As for invalid values, I think it is an advantage of the current API. I mean we can easily detect invalid values and return EINVAL. With your API, such mistakes will be undetectable. As for priorities, I don't see this problem here If I don't miss something. We can rewrite the code this way: ``` if (required_mask && ((page_flags & required_mask) !=3D required_mask) skip page; if (anyof_mask && !(page_flags & anyof_mask)) skip page; if (page_flags & excluded_mask) skip page; ``` I think the result is always the same no matter in what order each mask is applied. Thanks, Andrei