Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2436516lqo; Mon, 13 May 2024 20:25:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfjU1Bp2oo71C2ne1XddoMfyxVGjXqSUIUKJsgNtGcetRcHxZOR8ijxw48PaE7hdv57FhhhWR49Ypf9WRIQ08QBWnDytjzbegZ4gLbIA== X-Google-Smtp-Source: AGHT+IHUB9p6mwV1lbJa7RfR9f+TTbahnbCHYxh8OdNDDHeE7EKkZdw2oGSQI5Bb7FQLtiXD5AtX X-Received: by 2002:a05:6a20:1590:b0:1af:d95d:98e with SMTP id adf61e73a8af0-1afde103e37mr14098359637.29.1715657151096; Mon, 13 May 2024 20:25:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715657151; cv=pass; d=google.com; s=arc-20160816; b=yR0IWNLrnf/R0JI/abe0H+B7B2N88dtWoVs8kSwa6cghXKAJO521j2DgffU465DO+H 2lrctJLEKRF7A75SA+yg7syGsHkINK9EIfiX5jkyJdzDxGw9Vme5/FnVBL7oNr96PP4r RzpWOqNkoo05+idsuhzQCEtb3yil9tMZrX6VS+2wQb9I0gG+VRwkV4G5tjGrKsIfAgXB m9WMb/0CF83szGT67gQ2v1ioWm6TLQIzg2V45Ry8rYSUN3aLoQCo+fSwIxOaPSl3QuLu B2zQkgZAGw0RJsjrh8V/G8phHEvr26XzHgpMZ+FnkXASJ2oTLx1JpBt0WRpIHTGFwn7r hXwA== 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; bh=QatI3itQrD8q96SWPUWR41mFut+oLHKYbFDPPBrD1ww=; fh=kUi0VEy5gJeQUiVjzJwBL2J0VHbjg/XH6/zNSuIXxaE=; b=w0ltXkZG6/+upHWJk5jj65DsNl4fk022m8ghucub/hypaCogk3kHq3fPyV9fEoVAgV fPCNguI33BPwwtL954PQSl6QLqQNrxgzYWeNNp/jijuQHIILzFkK8PPCw4LFdD6dUPA9 k0OMzmL6EXq0/pDunI9EwJ7Gxr/JJ3WtKdMeZyk4yOUN9eayKMk8UKdaCEqTD7Ceizzt dIROBR2iXZ6BAWEOtYuXJRGP5HQT0HYRpPB6vX9uNBn4NLQ0kQALzIoFQ1E1PQJhPesu m0gc3ntBpgri/ISNemhRgg0amODZDOEibiJcYhHZAlbVQVjRIPx1VfGNOIbcA9IeUw4u Q1dQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-178291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6290c010fsi12686357a91.147.2024.05.13.20.25.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 20:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-178291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 88390B21D73 for ; Tue, 14 May 2024 03:25:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5125B66F; Tue, 14 May 2024 03:25:41 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2E4617C2 for ; Tue, 14 May 2024 03:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715657141; cv=none; b=jPr0it6+eMa6LnYMR/44KUugOyPtEFHZGBDqzSK2Lb/9n3A23t0AgPWbj1T/WS+diRjhBfkkq+pMYkNiorrskNw7grk0NgTG2uUq5frI8MRqxK1Yrp5CZl37brCs+jJSH44eJt1GuK/a/jKFKCnWCAtoO61qnD0r/bT+5xS5KBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715657141; c=relaxed/simple; bh=jk63Rm7ks9AdRCHsNPN6oDJWZW1fBSt+HTwGGngaXvI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VlZCu78bVl2+Vwhg9Mz/HwESWw+4EhwMKOwtyFCPpD2WRY6SM55DbzLiEq9c+9ioQDithw3s/cVnq/PbtdM2Fsytyv5k1imYB0hMSe69WkRNpfP1xtvkmgERnUEh3ycJOnQ4oiqFu/hKY8dht2bvGp9qyz2eDf3vH4d/VDmSoEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 788891007; Mon, 13 May 2024 20:26:01 -0700 (PDT) Received: from [10.163.35.194] (unknown [10.163.35.194]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA3373F762; Mon, 13 May 2024 20:25:33 -0700 (PDT) Message-ID: <3ade5078-0105-4d10-86d2-02806d48fbd0@arm.com> Date: Tue, 14 May 2024 08:55:43 +0530 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: optimize folio_move_anon_rmap() Content-Language: en-US To: David Hildenbrand , Chen Taotao , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240512123555.8358-1-chentt10@chinatelecom.cn> <7a4d4992-4c8a-43b9-8c41-a938bc3cec67@redhat.com> From: Anshuman Khandual In-Reply-To: <7a4d4992-4c8a-43b9-8c41-a938bc3cec67@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/13/24 21:07, David Hildenbrand wrote: > On 12.05.24 14:35, Chen Taotao wrote: >> When a folio belongs exclusively to one process after a COW event, >> folio_move_anon_rmap() always moves the folio into the anon_vma >> belongs only to this process. >> >> However, if the folio already belongs to the anon_vma of the this >> process, we don't need to move it again. In this case, we first >> check if the folio already belongs to the anna_vma of the this >> process, and only move it if it does not. >> >> The above changes may improve the performance of vm faults in some >> scenarios, because the performance loss caused by WRITE_ONCE() is >> much more than the performance loss caused by add a judgment. > > Please proof that by real numbers. I don't think it will make a real difference, and we likely don't want that change. Agreed, only scenarios when pre-condition check makes any sense is if subsequent actions are expensive such as writing into registers etc. But in this case both 'if' and 'WRITE_ONCE' statements are of comparable cost, hence adding additional conditional check is only going to increase the cost on average i.e when both gets executed.