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 553AEC43334 for ; Fri, 24 Jun 2022 18:40:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99A6B8E0263; Fri, 24 Jun 2022 14:40:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94A7A8E0244; Fri, 24 Jun 2022 14:40:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 811BC8E0263; Fri, 24 Jun 2022 14:40:58 -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 713378E0244 for ; Fri, 24 Jun 2022 14:40:58 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4977C33CA8 for ; Fri, 24 Jun 2022 18:40:58 +0000 (UTC) X-FDA: 79613996196.24.6F50276 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf22.hostedemail.com (Postfix) with ESMTP id D34E1C0003 for ; Fri, 24 Jun 2022 18:40:57 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id q18so2784472pld.13 for ; Fri, 24 Jun 2022 11:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ONsbNtaIj+2QckCbaSTtKTSn8S/ItxiojyAwz7e9USc=; b=cYLbrnirigZc9e24pjc6GvP6fvS5I7GIHhuZ1xkZbJEKdHhli3jKq0oNtLOOrhTBii OuuMg9jUcYJoVNn5/05AyqnRAXLvLN/sKPv9lJhLG0FMvvQtlPUMKtyCqXXHftUNKFzY BVbgsvv65PYSJ6an2Z4KK0svZOO7TCReB+EiZZIrtw6dYh5znz721u4AXR9NhaSgw0Fc co1zFzpLSe5ghj8fIWIVv8ZNRaZOJueRv2Cp3552VD+BxHdbaZ1N/bAEf7+Lg62JV0y1 19w2cBFP1vyb+JzfBOdaV9Ftv57XzBqScmgvEFpHR0jzj9Z/YEHn3HLrPZUtBy+dRxLi 8y8A== 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=ONsbNtaIj+2QckCbaSTtKTSn8S/ItxiojyAwz7e9USc=; b=TulfrNzUQZKNBCppriB0vA7oxrUDZtN51BVpA1wvYdFFn5H/ufhkzK512R1jYNQ17U XzyqPXtDrjGsVd8QsFKPviyKQMxASuXoXR8vDR5qxa1uQOyxH72JhplDJR6d+f0hIHYh 0WDZOf47DNqHhZMKONwkFUvjyLz2xK18xmjnqz0mvdY50OWTHI9/HktWLkOvfuHxV5mu znSSVrAVS1nfPxQAvVL3eRgHSAhw6TNkRVvSOhbvUNy8JDINC9YqZQChhXbHaRt6ku7J tphe9+aur2TDv+alTFBJ9ZsShBJXe7AQi4pqZjjuBTpdPkBi8JtT+TRAYRoLZYrXcWwp N1zA== X-Gm-Message-State: AJIora/WshRDrJ35HD0yqrUut60OQr/r6nzHzv0a9iEnBILimsZqtsls 7MXqhdUVuB37Gt3HXmtAZo5P6g== X-Google-Smtp-Source: AGRyM1vGr/sif3V7DYQiRNsgTb/FtTyE8ZlsUKZjm/7O5khucthxuW043co6l+yxIPQnKACg5C44Vg== X-Received: by 2002:a17:902:8eca:b0:16a:285e:5878 with SMTP id x10-20020a1709028eca00b0016a285e5878mr425735plo.59.1656096056633; Fri, 24 Jun 2022 11:40:56 -0700 (PDT) Received: from google.com (55.212.185.35.bc.googleusercontent.com. [35.185.212.55]) by smtp.gmail.com with ESMTPSA id t5-20020a17090abc4500b001ea629a431bsm2120609pjv.8.2022.06.24.11.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 11:40:55 -0700 (PDT) Date: Fri, 24 Jun 2022 11:40:51 -0700 From: Zach O'Keefe To: Miaohe Lin Cc: "Kirill A. Shutemov" , akpm@linux-foundation.org, shy828301@gmail.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/16] mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd Message-ID: References: <20220622170627.19786-1-linmiaohe@huawei.com> <20220622170627.19786-3-linmiaohe@huawei.com> <20220623031401.wdyt5ylin4aijzhh@box.shutemov.name> <7ee4a597-d7cb-f387-5613-f51b17262745@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ee4a597-d7cb-f387-5613-f51b17262745@huawei.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656096057; a=rsa-sha256; cv=none; b=g2+VcAwEew+9VHPTX6+9auWaV7r1h06hYNyOnqInwFEIZg48iTpvKaCQoYjMjQMv5IZHx3 hRhnt0NsrvXo6hJkVOQUwS3oUrJsenB2GtcTMS1Hq94/o2HSxXhI770MKALTdz7RZcjOAG JU+t9nOPj8+V5fNLnjWE6bcx13xtD2I= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=cYLbrnir; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of zokeefe@google.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=zokeefe@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656096057; 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=ONsbNtaIj+2QckCbaSTtKTSn8S/ItxiojyAwz7e9USc=; b=2XHLtzetKQKsGoWwSl1jN4rSsZKKLSv7zWX2ah4xs3AqWj9ufRKQDdvlpqUZgEkwIZblJm AfDHSZqDNDAlMlRdmG+BTsscK4McbsfMAdD6AhLRQrrEhALrY40RO2k5Yjpql2z5bN4vZH X1nRY0IHosaR6AW/5GMOFE8VNdP5lZ4= X-Rspam-User: X-Stat-Signature: rugceq4cddfdddwmimrzon64ks61hq69 X-Rspamd-Queue-Id: D34E1C0003 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=cYLbrnir; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of zokeefe@google.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=zokeefe@google.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656096057-821055 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 23 Jun 20:03, Miaohe Lin wrote: > On 2022/6/23 11:14, Kirill A. Shutemov wrote: > > On Thu, Jun 23, 2022 at 01:06:13AM +0800, Miaohe Lin wrote: > >> vma->vm_page_prot is read lockless from the rmap_walk, it may be updated > >> concurrently. Using READ_ONCE to prevent the risk of reading intermediate > >> values. > > > > Have you checked all other vm_page_prot reads that they hold mmap_lock? > > I took a glance when I made this patch. > > > > > I think the right fix would be to provide a helper to read vm_page_prot > > which does READ_ONCE() and use it everywhere. This seems more sustainable. > > > > This patch is inspired from the below commit > 6d2329f8872f ("mm: vm_page_prot: update with WRITE_ONCE/READ_ONCE") > > It changed all the places that need to use READ_ONCE. But remove_migration_pmd > is missed due to it's introduced later. It looks fine to add a helper to read > vm_page_prot which does READ_ONCE() but READ_ONCE is unneeded while under the > mmap_lock, so might it be a little overkill to add a helper because the helper > is used iff mmap_lock is not held? > > Thanks. IMO adding the READ_ONCE() as proposed in fine. Adding a helper to be called dependent on locking context still requires the caller / dev to know what the locking context is - so I don't think it provides much benefit.