Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1019882rdb; Fri, 22 Dec 2023 11:53:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLyaDj8t5KhoPjvjm9lLVgHJrYIkKnYxoQsVZBsdtrY5QVJWSsLoNJpchxB429/HhbEmEu X-Received: by 2002:a2e:988b:0:b0:2cc:1f8b:1b01 with SMTP id b11-20020a2e988b000000b002cc1f8b1b01mr1007185ljj.33.1703274781368; Fri, 22 Dec 2023 11:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703274781; cv=none; d=google.com; s=arc-20160816; b=PR3qvmmL+0PmhPYa2Cy5s3zGKmHiSsywDFQ8EYSdAONdv0EqBuum+UwGjPC7nye078 Mq7KOeC9aqvyvxDQ9I6iiTCKUKJsSUWQJMET43oDQGAF0HbhqS0XWe27ELgVbh1OMWBY mLwLF48AYCxQMKKd14150U4AnDCpMetUD84K3BL0DN9bF7bmOpe8eWqnEJs33K3uNHcI QcCauL6GnEaPU5GibqRQoKWW8YeqeLBhkkNlhrV6HwfEqfVjvlhbQjf0eSSyqpCPVRZa gAezwtHl2loCFGN2dswRX7UERn+0bwBT6Fjkkv/lWdAGltHTVj0pIc936rC9TQrLw7R6 NOAA== ARC-Message-Signature: i=1; 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=wF0SucCDjJdh7HZRNI84RgSHZWGk2eEUGYGdAuUxbgI=; fh=dQ3KO5lbfra8ertzghudGEMJYYNq+WCtnGsPskqyPDc=; b=k4gtkAIy6wI/CWs7Jm7waGBV69PUTtBjSR0SKG+EJ0yk99welwLt9BYOdhlxNkIxuN tSf8tQsPcGMuSJ9nQ4NOK74yQDyE4A7Y5gnRZ5CxZ5UIr4EXw2FaEIxJwIq/WPQiirTQ oYDQ0SdrROCJFBkkkLz+r2EuzeZ9UW9GNDkfIGXL0PZQW6m8OsfdHEjgfbhYPKehb/tp pvBLoa6JK+vy/VfTHnnMgu+4FXieuHnzcBeXsTuw2/GwFuTyNpWFylgHDdDwzY/bgPm4 rHcvIWyGjEM0X3WBvB4ZEpkj4SoKC6LNdp1DBN0Q5fBNwGiBAHdFrWVQ7Q7ylzW6035Q wpvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tdUfleNz; spf=pass (google.com: domain of linux-kernel+bounces-10034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10034-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z12-20020a05640240cc00b005547e96a176si121290edb.94.2023.12.22.11.53.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 11:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tdUfleNz; spf=pass (google.com: domain of linux-kernel+bounces-10034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10034-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 209FF1F23AB1 for ; Fri, 22 Dec 2023 19:53:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A9802F85D; Fri, 22 Dec 2023 19:52:11 +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="tdUfleNz" X-Original-To: linux-kernel@vger.kernel.org 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 6A1412F849 for ; Fri, 22 Dec 2023 19:52:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48A18C433CC; Fri, 22 Dec 2023 19:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1703274729; bh=9/goXFkgxBVSNEPhlQK8ZimkF0PGBTWUJgfmfSTrhhc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tdUfleNzIZFzv+duf7Rv5BjnJJXD/ix8hHCOZDGsfcEXuMLvvm0JikroJIDhQUVOX bQ8+602rys/dcJVv4TpBVPr839CfHwNJHse7M4d5XfrQb06T9EbE4pc9DqVr3Pbv7I bNRx0DO6xGsj/pgzkzW3VXZdNFJ0X+FfuHBkK4tc= Date: Fri, 22 Dec 2023 11:52:08 -0800 From: Andrew Morton To: Chris Li Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei =?ISO-8859-1?Q?X?= =?UTF-8?Q?u=EF=BF=BC?= , Yu =?UTF-8?Q?Zhao=EF=BF=BC?= , Greg Thelen , Chun-Tse Shao , Suren =?UTF-8?Q?Baghdasaryan=EF=BF=BC?= , Yosry =?UTF-8?Q?Ahmed=EF=BF=BC?= , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song Subject: Re: [PATCH] mm: swap: async free swap slot cache entries Message-Id: <20231222115208.ab4d2aeacdafa4158b14e532@linux-foundation.org> In-Reply-To: <20231221-async-free-v1-1-94b277992cb0@kernel.org> References: <20231221-async-free-v1-1-94b277992cb0@kernel.org> 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 Thu, 21 Dec 2023 22:25:39 -0800 Chris Li wrote: > We discovered that 1% swap page fault is 100us+ while 50% of > the swap fault is under 20us. > > Further investigation show that a large portion of the time > spent in the free_swap_slots() function for the long tail case. > > The percpu cache of swap slots is freed in a batch of 64 entries > inside free_swap_slots(). These cache entries are accumulated > from previous page faults, which may not be related to the current > process. > > Doing the batch free in the page fault handler causes longer > tail latencies and penalizes the current process. > > Move free_swap_slots() outside of the swapin page fault handler into an > async work queue to avoid such long tail latencies. This will require a larger amount of total work than the current scheme. So we're trading that off against better latency. Why is this a good tradeoff?