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 84B88C433EF for ; Fri, 3 Dec 2021 06:46:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08E76B0075; Fri, 3 Dec 2021 01:46:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB8296B0078; Fri, 3 Dec 2021 01:46:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 980A16B007B; Fri, 3 Dec 2021 01:46:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 882016B0075 for ; Fri, 3 Dec 2021 01:46:00 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3F0658088F for ; Fri, 3 Dec 2021 06:45:50 +0000 (UTC) X-FDA: 78875547660.08.E3EACC0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 49E0530000A0 for ; Fri, 3 Dec 2021 06:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638513949; 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=B0n7JcNAcYn+Bd11okNue8IqT9XrfBBrxPPRZCGg20A=; b=XZZGPtpeyVaHcfgnJq0Wqoq3RYIvLKVFTIdJ/z8yZScgR9zIHi1fbArBEv2vkKt7ovKHmT CqphCpcl9Yy1XOml9tIqTZJ+3U+ub/fOsYP+JqPS6JmUe11ryukRBw3BWkTqtS8AVouMys TMUlA0W7TccY/YnpbjuPWF44jmcnEzQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-203-QrqXRA1zP9SUkjfjFpTWCg-1; Fri, 03 Dec 2021 01:45:47 -0500 X-MC-Unique: QrqXRA1zP9SUkjfjFpTWCg-1 Received: by mail-wm1-f72.google.com with SMTP id m14-20020a05600c3b0e00b0033308dcc933so915199wms.7 for ; Thu, 02 Dec 2021 22:45:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=B0n7JcNAcYn+Bd11okNue8IqT9XrfBBrxPPRZCGg20A=; b=3v3hD72j0xhISl92tZ+F2Ot6Xtzq18n82NlpbjCjKUmuF+BzA1nhonCElhaFvmfolu FE+wRSK4Y+ji37j5AbH4vDMu0uKYGIUOscBuGyKtNpP4M+CQCrc5NCCek9T6I+ErAMWm ZS3u04mzlGwIn5CfMWSdiVqoz46Pvex991Cfz08dsGZ4ahBQg3eOMpI8B5L0xdS63XxN /aZ8cdcCOrg5ImQjqW2MLTtUFe7STPRf0gvkn+T1J+N/bHiTOTla32Flekjs6BTx2NuZ UCmxzFdUjRmNQjKDHEFOgYepmwfsBsfSjPskkQD/axWhycSS+GVIkMsoZF2xHd5EUdof QfQg== X-Gm-Message-State: AOAM533nUuLh5SSgB20Goi4w00SZxAEw1b5IYDR1lgQxjh/l7ohTr4qB c8cPVE3CwxhqQeosmS3bUfed0lKrcCE+I+ZAi07vwg4JEPKUDZdDAQo8PMNmb1BYe2HrKh5bxkr eO9yO6ZSgStQ= X-Received: by 2002:a05:600c:d0:: with SMTP id u16mr12211155wmm.7.1638513946727; Thu, 02 Dec 2021 22:45:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4QxLQdwPZWAy1sF4nI2kLftVNVchu51EysUwQMm50HtRmJU/m6AC98u7ekwAGwe+6P2l5Zg== X-Received: by 2002:a05:600c:d0:: with SMTP id u16mr12211119wmm.7.1638513946428; Thu, 02 Dec 2021 22:45:46 -0800 (PST) Received: from xz-m1.local ([64.64.123.26]) by smtp.gmail.com with ESMTPSA id o9sm1810290wrs.4.2021.12.02.22.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 22:45:46 -0800 (PST) Date: Fri, 3 Dec 2021 14:45:37 +0800 From: Peter Xu To: Alistair Popple Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen , Nadav Amit , Mike Rapoport , Hugh Dickins , Mike Kravetz , "Kirill A . Shutemov" , Jerome Glisse , Matthew Wilcox , Andrew Morton , David Hildenbrand , Andrea Arcangeli Subject: Re: [PATCH v6 01/23] mm: Introduce PTE_MARKER swap entry Message-ID: References: <20211115075522.73795-1-peterx@redhat.com> <11462319.U46FXHIEPT@nvdebian> <3832555.7SGzcYD3YQ@nvdebian> MIME-Version: 1.0 In-Reply-To: <3832555.7SGzcYD3YQ@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: ger9f5qh8k3e7psy8cnuw8hcjxa3k43r Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XZZGPtpe; spf=none (imf08.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 49E0530000A0 X-HE-Tag: 1638513952-799652 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 Fri, Dec 03, 2021 at 04:35:38PM +1100, Alistair Popple wrote: > > > > +static inline pte_marker pte_marker_get(swp_entry_t entry) > > > > +{ > > > > + return swp_offset(entry) & PTE_MARKER_MASK; > > > > > > I'm not sure the PTE_MARKER_MASK adds much, especially as we only have one > > > user. I don't see a problem with open-coding these kind of checks (ie. > > > > It's more or less a safety belt to make sure anything pte_marker_get() returned > > will be pte_marker defined bits only. > > > > > swp_offset(entry) & PTE_MARKER_UFFD_WP) as you kind of end up doing that anyway. > > > Alternatively if you want helper functions I think it would be better to define > > > them for each marker. Eg: is_pte_marker_uffd_wp(). > > > > Yes we can have something like is_pte_marker_uffd_wp(), I didn't do that > > explicitly because I want us to be clear that pte_marker is a bitmask, so > > calling "is_*" will be slightly opaque - strictly speaking it should be > > "pte_marker_has_uffd_wp_bit()" if there will be more bits defined, but then the > > name of the helper will look a bit odd too. Hence I just keep the only > > interface to fetch the whole marker and use "&" in the call sites to check. > > Why does a caller need to care if it's a bitmask or not though? Isn't that an > implementation detail that could be left to the "is_*" functions? I must admit > I'm still working through the rest of this series though - is it because you > end up storing some kind of value in the upper bits of the PTE marker? Nop. I'm just afraid the caller could overlook the fact that it's a bitmask, then there can be code like: if (is_pte_marker_uffd_wp(*ptep) && drop_uffd_wp) pte_clear(ptep) While we should only do: if (is_pte_marker_uffd_wp(*ptep) && drop_uffd_wp) // remove uffd-wp bit in the pte_marker, keep the reset bitmask I could be worrying too much, there's no real user of it. If you prefer the helper a lot I can add it in the new version. Thanks, -- Peter Xu