Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1585426lqe; Mon, 8 Apr 2024 13:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFEXAiZ6PstZ89BvrPyk3/AKgN85kDqbtPfAck0KHP+w4sUP7P64cu2Qjbh1xUZvhMnameAiIrShc0o915a4+B3Es130jqhMq0OaNftQ== X-Google-Smtp-Source: AGHT+IEMj5otY3SZ4glQdoJbJ2nGoKhq48V+ggIbMr/HMOCeNHk+I6uMfMGNM/O6Gem6STcH0QYn X-Received: by 2002:a05:6a21:789c:b0:1a7:5425:498c with SMTP id bf28-20020a056a21789c00b001a75425498cmr6396649pzc.2.1712608032198; Mon, 08 Apr 2024 13:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712608032; cv=pass; d=google.com; s=arc-20160816; b=ERV9Wp+QWOfMofwsymtH3cnRdFQIPn9i2Ygyg28HyZ8lt8SdfWJkHSxY6K2oTFOgj9 1fVzEp6EGB2t9oRPToiogNP+PX7HJf+i4UHLcWi87JwYtvuhgRHuWNpXjVZZh/bd9F6E iCYmUdTp0+kj8fI1qRAkiCa6sXyT6M0g0r1caJWCEgHg0p39Pmfwwnoss+bsETB+Yse5 vJnfMYY3ZLH2vbXHHdXgrtx1fzBcK8oZmPDfz4xHVLdJUpI6WcfrETE10uzug/78kg2L ljgZGZlE5vQmj7NxHTe/KF5z7QB4JghF2Yl8VOA1jRJ78x0UakbvapmcyIKkuUpP8+ed UXyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=rK5tsvHoYYDsupdDWS0AP2E3vvdrqLD+vRmYtgDWOl8=; fh=fr88y4KkORMEoyOrxfxIdxIVwt0Wt92aVFp7AfoFelA=; b=BdmOAt8A2xBiWr863aTuhpJ6zUF/QlL4BF8n4qt+qz7Sux2r9FR9alUMHoS6Tdp2ze sSZIDg25sIo+RBj3+tqa9sN/1+MeN+jlIx7oLkaz0Y07F0l8PT7ZyzqAsCah2zz/UUwP p6KaUzroUonyGcw7Tnt76U6SiTpayfZWnwrsdYL3Xu1KJPTF4LkhXvmgMqkgtEkbJHc7 H28o5x3nb5CUz0688qWd3+LIR4EVFkG5Nw7IxoKDcue5ObrbRjE0IXPm2mcTdOh3ePdF ztw3t879yvJqn+2tqgno4sL4pxnCY1CbBL2YZqca0jHO+10ZEgwgSIUupd3IB/v4rGA4 Ubqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="F/BPrRsx"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-135905-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135905-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b3-20020a656683000000b005d91365dedasi7030291pgw.613.2024.04.08.13.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 13:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135905-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="F/BPrRsx"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-135905-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135905-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D18A62838AF for ; Mon, 8 Apr 2024 20:27:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90E33146A7D; Mon, 8 Apr 2024 20:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="F/BPrRsx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B04C3143C59 for ; Mon, 8 Apr 2024 20:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712608025; cv=none; b=UouQ0stYWBRkprLtNafc0FyJ7XG1pa2BfzqDZOVAlQL1yDyYFSUSzuocA8N6Tg4Tu9Zm54ohaXb+F/2hmJhK/STHNeZ9iaUEmSdsdu7075MSKzAOcUD2UgQF69QpTa+zpjbqk6XYvHfxPQgua/y6i/PD9lPTdIFoRRweNwM7ADI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712608025; c=relaxed/simple; bh=6R2p51QAJCwDeoOozdngxiQ1aMNdwu7wefjZs0Nt9wc=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=TQkJdk1g++MGnZsIH85YJqjrR0xjdLDJQBTGY4GT54ZuZtFu8xY/9coWhvPzfbjCm20UbogV/jMPeIpkO7SQ/Mfn2mfBXzWm66er7/AFSH6eBxbvzCKoVy2F0bszhqzXMM8EKMcDAegrxIrE3vL3E4f7iZFVgX+6sUk0uQPU1Kc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=F/BPrRsx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAEB3C433C7; Mon, 8 Apr 2024 20:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1712608025; bh=6R2p51QAJCwDeoOozdngxiQ1aMNdwu7wefjZs0Nt9wc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F/BPrRsxLcRD+zrHJ0pN5yyHBjted1v3/R3IClIViSUuy3is0T/5Ifxz3uTx6K8ah pNenFwxlssa+d0X1QDoMF2JRvB7xrIBKr5/q9OZvCUp/hLlqFgx5810Y1krfwnBvCJ m429JxhTEeIqkQNbpUgbqj/LqYxLQfqwCzF+OAQM= Date: Mon, 8 Apr 2024 13:27:04 -0700 From: Andrew Morton To: Zhaoyu Liu Cc: ryncsn@gmail.com, nphamcs@gmail.com, ying.huang@intel.com, songmuchun@bytedance.com, david@redhat.com, chrisl@kernel.org, guo.ziliang@zte.com.cn, yosryahmed@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm: swap: prejudgement swap_has_cache to avoid page allocation Message-Id: <20240408132704.f966adc8d3928df4d3b8c0a9@linux-foundation.org> In-Reply-To: <20240408121439.GA252652@bytedance> References: <20240408121439.GA252652@bytedance> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 8 Apr 2024 20:14:39 +0800 Zhaoyu Liu wrote: > Based on qemu arm64 - latest kernel + 100M memory + 1024M swapfile. > Create 1G anon mmap and set it to shared, and has two processes > randomly access the shared memory. When they are racing on swap cache, > on average, each "alloc_pages_mpol + swapcache_prepare + folio_put" > took about 1475 us. And what effect does this patch have upon the measured time? ANd upon overall runtime? > So skip page allocation if SWAP_HAS_CACHE was set, just > schedule_timeout_uninterruptible and continue to acquire page > via filemap_get_folio() from swap cache, to speedup > __read_swap_cache_async.