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 13776C433F5 for ; Tue, 4 Oct 2022 13:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C3AF6B0072; Tue, 4 Oct 2022 09:49:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 773C68E0001; Tue, 4 Oct 2022 09:49:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6139C6B0074; Tue, 4 Oct 2022 09:49:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 503626B0072 for ; Tue, 4 Oct 2022 09:49:43 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2667140DA1 for ; Tue, 4 Oct 2022 13:49:43 +0000 (UTC) X-FDA: 79983399846.09.9CE00AE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id B855320007 for ; Tue, 4 Oct 2022 13:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664891381; 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=eSbZxDSZa0MB8ZF/Gz/fWRW6UQaKjwrDHpdispjH1M8=; b=g1fHInRHQRZnXz/vXDS4hpksQ5vEwWDO6Py4BR29ywyPuRF7Yh+MCvowmHcxAKLA2KY6nT Jkir6/Mogtg82C9Ij7RebLQjdDfJDfeC57XyD7TDqCa2h/yb1R/2PK5CUf5RMfhtu+89xJ 6GFKw/lj9M94gUwwgtWgbJMWv5gEH8g= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-231-QjS1OuneNUazTUHbc-HBBA-1; Tue, 04 Oct 2022 09:49:40 -0400 X-MC-Unique: QjS1OuneNUazTUHbc-HBBA-1 Received: by mail-qv1-f71.google.com with SMTP id h3-20020a0ceec3000000b004b17a25f8bcso5621431qvs.23 for ; Tue, 04 Oct 2022 06:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=eSbZxDSZa0MB8ZF/Gz/fWRW6UQaKjwrDHpdispjH1M8=; b=cgu5KIgurzRvdKX0ZL2Ssrz6/v0Fcnbjysh8huA0SDicvQt+e3pGelyc6wIy6IKO2r ZfT3/JNQn/ALyUtntrFuSrgGpv2nzHNOBIUmiCYvVd/jLS/4QAaoI1FEMeN9n4wnERxK K0yENTxxvmY0S0svSE6jqdLX8NKQQ7KONIBeW5LAOxTJfQ8TlCdJ0ZNOToOl/PbXL5ex mCpfagijRn1+sWdhjiIqYRqsWxgiamqWrJnocyCnAjTmG2/bDZhzaNykUTE7Mavid0wo 04KyjIWsItVCnvvEEPA8Wr6t274+CuPFrbJT+xZwi2VYR6xX4jJCE1v4JrG7FGESkfrl JaCQ== X-Gm-Message-State: ACrzQf08SG9CcmTyoiShBfDyKtuYe6Gs96h8s8jD+56QabWnTnLhBtWL zshq4m+KSG29JXwJOQJ4595E/8gYzZuRjWONb6QHRMNmVoTVNPmjKvc11XVdiRg0kwzWlU7EN/D T2JW4mORGEXE= X-Received: by 2002:a05:620a:f0e:b0:6cf:beb5:a28 with SMTP id v14-20020a05620a0f0e00b006cfbeb50a28mr17115901qkl.738.1664891379857; Tue, 04 Oct 2022 06:49:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LxMm7nV9MgnbYAFEedzhXQ/r4UiO7lrTm2ZvfXZdx6zJM21f1TQE5VMTOTWUginb5wHunpw== X-Received: by 2002:a05:620a:f0e:b0:6cf:beb5:a28 with SMTP id v14-20020a05620a0f0e00b006cfbeb50a28mr17115886qkl.738.1664891379646; Tue, 04 Oct 2022 06:49:39 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id h16-20020ac85690000000b0035bb8168daesm12238061qta.57.2022.10.04.06.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 06:49:39 -0700 (PDT) Date: Tue, 4 Oct 2022 09:49:37 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Nadav Amit , Mike Kravetz , Andrea Arcangeli , Axel Rasmussen , Mike Rapoport Subject: Re: [PATCH v2 1/3] mm/hugetlb: Fix race condition of uffd missing/minor handling Message-ID: References: <20221004003705.497782-1-peterx@redhat.com> <20221004003705.497782-2-peterx@redhat.com> <41fb1d6c-0d36-e88c-39fe-ea1e9d80a1fc@redhat.com> MIME-Version: 1.0 In-Reply-To: <41fb1d6c-0d36-e88c-39fe-ea1e9d80a1fc@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664891381; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eSbZxDSZa0MB8ZF/Gz/fWRW6UQaKjwrDHpdispjH1M8=; b=LwDhBgPQ4Svi7R1j5g0ip6aLY7XLbzzhUDzprCr0tU7vabwEvU4yCT/h5r2+yJbpuIR+CJ GEdgpyFu1kjNJf2/KG2ztrTKaMCIVchw8UDqfZHnnwbG7quN5Xq5SxIRxuO6ncAxfhiiKU JKNoFa2eOGWJb+24qgOgeIeumHn5F2o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g1fHInRH; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664891381; a=rsa-sha256; cv=none; b=pyG/8o9hpII17xGFdZLfXGLIwAz8K07HyBICR9Pt9d/cTddEautWVjY8uUDmhbyNhYNTPL LszrFQj6mopZHkHlQpQZQpFV8TsNb+ZgrkqzeecrRmwZmMhTzRIFGAq9V9PRQFPl+MszE0 GaJNvVSTPyx99XsLK0LXCxDNWUQ2VPQ= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g1fHInRH; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B855320007 X-Rspam-User: X-Stat-Signature: q9cab6xcb14cosqu38jnzrbhp5kgy6x7 X-HE-Tag: 1664891381-99585 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, Oct 04, 2022 at 02:19:36PM +0200, David Hildenbrand wrote: > That looks kind-of ugly now. I wonder if it would be worth factoring that > handling out into a separate function and reusing it at two places. Would > get rid of one level of code indent at least. > > Apart from that, LGTM. Although the lockless reading of the PTE screams for > more trouble in the future :) Right there's potential to further rework it, I am just not sure whether that could be common enough so that we can start to take pg lock for the whole region (then we'll need to release for either page lock or alloc). Not really sure whether that'll be worth the effort. However, at least uffd minor doesn't really need the page lock so we can optimize it with a find_get_page() earlier then the missing mode can be moved over too (following a lock_page?). Maybe I should give it a shot. For this one I'll keep it simple since I think we should have it for stable too. Thanks for the review! -- Peter Xu