Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2191740lqt; Mon, 22 Apr 2024 04:25:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFowypIo6vHoxNQ9AyCZ6KhIytN1Y5H0PhHNf2grZLiJ5T57AgDWSQRpkHV+w7ujZ65BDRLsy08eZCi5nPy1reMc61dG6C/9AUZfjvRg== X-Google-Smtp-Source: AGHT+IGj611I+Z/opmkjOfbFr0VzkIU/RQ9nO7fdIg3mn6PrCwWl5eIg5zSn+KhnzokbUQANDXzb X-Received: by 2002:a05:6512:3d24:b0:51a:f48d:7b31 with SMTP id d36-20020a0565123d2400b0051af48d7b31mr6238908lfv.13.1713785114991; Mon, 22 Apr 2024 04:25:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713785114; cv=pass; d=google.com; s=arc-20160816; b=B59Z2SUtL/84bZ3RH9IoFzXsz4MrptH/BlT0GV/CtxX0tP9WDY1tcwLzIGFsZkXAmU jiiArm8j1nL5ontv39MyVFuhV4tfxjQekpLN3EKCiZBNql/+cj/4w2p3UmoKybSvQ59e pWzS8v8HqnNJ+gv+wmerYuOU8NEBWvy8XwE3OK0M0kSbyJmfeQSvU/lnTsSMb2v3Jzy7 9NsB+wWJm2klCTePs8lggv68HsXssa7C1tH+gEFWgt904HMk45ueweGnfZ0mst+vPgT2 jood7uxIQtDTepKYGhy/vwSsudYZFt2ehvhVwJq68aw5Vn100I+C6hrz7+y7OkILjf9O SoBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=cfhbsSjSAQpd7XXl3LTfiYiNn6Efgvd2Ye+Gxcm0xhc=; fh=fqiXRPAQ4I2uipXAxC39LdvvCjFAof5Vg8R26wiBQkI=; b=pjwvROcMIiDvGSoaxLRF9HxZN8iDgsVT2XU5TjDtFkZRKAhvFRhrklH3gRP1fDL+am 5gdNx9/3+Al2rRNpy/UFPw6ahxVpP1hCtTGmjn6QodnuE+75nvn89XVE+ucnOVGmrr4N 9BZdTzlwULiS4n1tH4FndktlJ6ybqnMkYyMDlkFJA3dLoiVPpryENOOOE1nR0hOLh5ns Wqc5lrHFe7Fbkqo110O+rmzYlKEOrbyB9gslyZcIiNr1P2jO0EEQZuGVOw8YuzTEA4b+ 7QsIVfurmqC1ZW/ML+ayX3uBjq9AmW4qlrWAK0xYdhpKp3540WWQ1D9bFZzPpyqM68vX QTHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=f45XrFAn; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-153286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w20-20020a170906385400b00a55d4837f04si466713ejc.36.2024.04.22.04.25.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 04:25:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=f45XrFAn; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-153286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B2E401F21977 for ; Mon, 22 Apr 2024 11:25:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CFD41465A6; Mon, 22 Apr 2024 11:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="f45XrFAn" Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78B76146591 for ; Mon, 22 Apr 2024 11:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713785106; cv=none; b=knebgGCyovUvgHetOxRMm2nHYT855Umjw74HPKeNj0cXGwcpbpwXhAxBC+RXxxHAofkqGFtdFQGwV6fSwlhjhAIjDEljpbSS8qeAc2dn9tjkmBR2cF+3ySPrnTrALTe5VV5Ss6DePf7Lsd4eQUBBtieEnN4+8cRUpTyEdHNyYcs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713785106; c=relaxed/simple; bh=0au7eGUl2EoSbXg8ChxoL5k6QP9ZDvXQU+TKvB3vxDQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Hsrjwf3sKQMT35rGwdTv16I0wjEGww0ITW55wOCJLiHBByWOt95BI6nnG/rfqXVXKz2yMaK9a75qT7D8W37ZFwZ5VDUt0xBEQ/GsNmGqvCIZfrF21CfHP7aq1DLCRk3xLZAXzzu9i/Yk4pP/NjpPGwsI1bqbWWq/l3wuWblYZqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=f45XrFAn; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2ac074ba920so619299a91.1 for ; Mon, 22 Apr 2024 04:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1713785104; x=1714389904; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cfhbsSjSAQpd7XXl3LTfiYiNn6Efgvd2Ye+Gxcm0xhc=; b=f45XrFAnnGnbu4L38rndx4jqxCcnJaY+u5YWcvA28KxK0fIO0qSKXA2mtlcgF643zZ gjCOXVyKa3OJOpEd2dOgw8sXPZaJ97EOhr/FcFMLHM/8iNsMNk2lYYnXuYOvhbcUrdQV Vf75CZ1OMbgv30InbdxJsyOGvOl9d0mv+cBsJ7V2VhDadSP5EoCDsGAhGfH+nEngmp2z yTvYfIztMGvN7dCMRxwAGVv29ZR9Y6fXNtcCJG3WxWnbIgFrabJ4ep8vZiEoxj6COQ+l iYzKM+1+WbIJbtx+p6rrQ3MIet5Qdei09Lg9Sg2DR2sXxJq2qGF2k9MUbrO/frFPhPZw 8WYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713785104; x=1714389904; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cfhbsSjSAQpd7XXl3LTfiYiNn6Efgvd2Ye+Gxcm0xhc=; b=d3xW1ij4D6eOPwz3gG4ZSqrX2IsAr5Paeyixa+/jFEnqQS2mmIHXSr/g7GIqcM96BM EeB7/1YH6Jc65h6hffcT6InPLXmrkLx6IVIf1ZfghsA3N2oWlq2moTsDaXJatYLQJe73 UuTr9TDLDP7p5nKb+HIukWudtIvLnx/TsAfdurq+aHTW09nhT7d5a6VaAEWxR1MSsXVR alxXajSK019qpubegaVZEuRUxK+htMdwepl7uOIMc398mMfHj0gb4LZ03e3cKmtuoNhA fhG7OpgKpF4Ek65RTbtcBJtV0aK8v9wG8lO46I4CH+vXStS/a5oD69udFWx3uvepreXA ZN+g== X-Forwarded-Encrypted: i=1; AJvYcCVSGagfOLFJxOWhm7IX6+qkRltLdsywDOvm474ATKKO/ia2Xw81cNJie6mJ55YlioPiANaB4XpyeHD6Oj9VwwaF+shKz00ekponkTiO X-Gm-Message-State: AOJu0YyVQuZmAY0QRGmw8tfX4kHW4tHJe/R93BPinvaPnQmgOPXwcIXu T6ezhGQ9uBQHxoP+BZV0+htzUxclewwo5dBcyj4t/FrGV3cUXgROl6aECiM7pAOiADyH/vlYs50 J X-Received: by 2002:a17:902:760d:b0:1dd:de68:46cf with SMTP id k13-20020a170902760d00b001ddde6846cfmr10786587pll.6.1713785103696; Mon, 22 Apr 2024 04:25:03 -0700 (PDT) Received: from [10.84.154.17] ([203.208.167.148]) by smtp.gmail.com with ESMTPSA id w8-20020a170902a70800b001dd82855d47sm7865852plq.265.2024.04.22.04.25.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 04:25:03 -0700 (PDT) Message-ID: Date: Mon, 22 Apr 2024 19:24:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/rmap: remove unnecessary page_table_lock Content-Language: en-US To: Yajun Deng Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240422105212.1485788-1-yajun.deng@linux.dev> From: Qi Zheng In-Reply-To: <20240422105212.1485788-1-yajun.deng@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/4/22 18:52, Yajun Deng wrote: > page_table_lock is a lock that for page table, we won't change page > table in __anon_vma_prepare(). As we can see, it works well in > anon_vma_clone(). They do the same operation. > > Remove unnecessary page_table_lock in __anon_vma_prepare(). IIUC, the page_table_lock here is not to protect page table, but as mentioned in the comments, to prevent concurrent modification by multiple threads. > > Signed-off-by: Yajun Deng > --- > mm/rmap.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 2608c40dffad..e894640a9327 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -187,7 +187,6 @@ static void anon_vma_chain_link(struct vm_area_struct *vma, > */ > int __anon_vma_prepare(struct vm_area_struct *vma) > { > - struct mm_struct *mm = vma->vm_mm; > struct anon_vma *anon_vma, *allocated; > struct anon_vma_chain *avc; > > @@ -208,8 +207,6 @@ int __anon_vma_prepare(struct vm_area_struct *vma) > } > > anon_vma_lock_write(anon_vma); > - /* page_table_lock to protect against threads */ > - spin_lock(&mm->page_table_lock); > if (likely(!vma->anon_vma)) { > vma->anon_vma = anon_vma; > anon_vma_chain_link(vma, avc, anon_vma); > @@ -217,7 +214,6 @@ int __anon_vma_prepare(struct vm_area_struct *vma) > allocated = NULL; > avc = NULL; > } > - spin_unlock(&mm->page_table_lock); > anon_vma_unlock_write(anon_vma); > > if (unlikely(allocated))