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 00C61C433F5 for ; Tue, 7 Dec 2021 02:32:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65E306B0072; Mon, 6 Dec 2021 21:30:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E5E16B0093; Mon, 6 Dec 2021 21:30:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 412396B0096; Mon, 6 Dec 2021 21:30:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 2B0B56B0072 for ; Mon, 6 Dec 2021 21:30:40 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DF6021817E60F for ; Tue, 7 Dec 2021 02:30:29 +0000 (UTC) X-FDA: 78889419378.09.1B18CA2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 62ED31906 for ; Tue, 7 Dec 2021 02:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638844228; 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=uinQkAT8jXoUvyzyhCOVwlkCtrtOX2gIF/TEODj1I7E=; b=TDcBJbgX5o6J1RDVrN3wlcOsba2EhNWlKbm/tNIq/IqMG1TxFz/Yuh1umhIbp2NE2mAc6H 9zIAe498B7JvSySTtTetZYpij0Iae1QfNVweT+XG5jGZ/InWUB85V1b+CIyGLSd96/xyFy XTCQAampub1TLZeZBJsbXXSOxnbc3QU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-lm0tU-PpNxCTzcJat6Rh1A-1; Mon, 06 Dec 2021 21:30:25 -0500 X-MC-Unique: lm0tU-PpNxCTzcJat6Rh1A-1 Received: by mail-wm1-f69.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso465234wme.8 for ; Mon, 06 Dec 2021 18:30:25 -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=uinQkAT8jXoUvyzyhCOVwlkCtrtOX2gIF/TEODj1I7E=; b=NZNCEpTuMBfyBtq7f7jzEfnakmZim1QLnysAkASGiIzWD07WriorGplu7wKCxf2OFi NFN58Py3F7ARWmNCUtAimOvAmPVE3Iqvk+yTHRxolNwom8F9Fn95Mqjtnkl1EnKEI0nI ksfBPA545fs5ke643ooDHkaIOZfLXGoRhFgoeBqI+9BfKdDuW+YDf3BFQLCGU89pMR7+ ++rdBT2KRVvps6fRHhWbqmCYymtBKb32AOS6fnmk6BekX4MxpH3ppn1X1IrQpVenX5Xn uq+HrHwSmInX5lsMimFaQDydlGV2U5gD7z+mkOcO4Og9xpnxEp+PMSntUv/6ZRMfmUir h+Rg== X-Gm-Message-State: AOAM531TUbFc3WsdFDSSCDPlpAU+U/q3fBEPOLIfm4sQtqo5TfPQSugv Mrqszd9QrkJzol0KRF4Ee0uPDQTJzAYjBPQUNSArM0725Asof/cJQRm12+2ruDctG8YkQv3y3X5 HmEFeiZXMnJw= X-Received: by 2002:a05:600c:4982:: with SMTP id h2mr3206056wmp.4.1638844224364; Mon, 06 Dec 2021 18:30:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeVKI+ZZziPdOTSoGsMuoEIaeoXMQlA2tWiydlHsa+VaTJOSQSgnLr7MLbYzRBe16eEVXBdw== X-Received: by 2002:a05:600c:4982:: with SMTP id h2mr3206029wmp.4.1638844224132; Mon, 06 Dec 2021 18:30:24 -0800 (PST) Received: from xz-m1.local ([85.203.46.174]) by smtp.gmail.com with ESMTPSA id l26sm1112119wms.15.2021.12.06.18.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 18:30:23 -0800 (PST) Date: Tue, 7 Dec 2021 10:30:15 +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> <3832555.7SGzcYD3YQ@nvdebian> <2190897.LADUpQAO2C@nvdebian> MIME-Version: 1.0 In-Reply-To: <2190897.LADUpQAO2C@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 62ED31906 X-Stat-Signature: f5zkkuwnec94u9ta5s38i4k74k7dpyrn Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TDcBJbgX; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf22.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-HE-Tag: 1638844229-62107 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, Dec 07, 2021 at 01:12:23PM +1100, Alistair Popple wrote: > On Friday, 3 December 2021 5:45:37 PM AEDT Peter Xu wrote: > > 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'm not sure how having the helper function prevents or changes this though? In > fact I just noticed this in patch 8: > > if (uffd_wp_resolve && > (pte_marker_get(entry) & PTE_MARKER_UFFD_WP)) { > pte_clear(vma->vm_mm, addr, pte); > pages++; > } > > And if I'm understanding your point correctly isn't that wrong because if there > were other users of pte markers they would inadvertently get cleared? Unless of > course I've missed something - I haven't looked at patch 8 yet for context. To > help with the above situation I think you would need a helper for clearing > ptes. What I wanted to say is pte_marker_get() will make sure the caller will be aware of the fact that the marker is a bitmask. But it's true at least my example might make it even more confusing.. > > > 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, > > It's not a massive issue, but I do think either defining a helper or open > coding the bit check is clearer. I think we can worry about other users if/when > they appear. OK, I'll add it. Thanks, -- Peter Xu