From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (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 5538FAD24 for ; Mon, 6 Jan 2025 04:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736139556; cv=none; b=OuGlK/kK9k4HCn6ndaVt+b2jKzxhEs3Zg2A6hh7naMBXVBp5E7jlHn9ik6eVScJcrp6AfmE5ATxdXZHbAx+oBx5WS7+NjA8914TQP1iQVcaN7b30gP6OO4ls1Wuo6oFN8GWH37XLD+26iYhE63dCPJ0r/n3hQ8hX6rLOdgFaObQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736139556; c=relaxed/simple; bh=3z9LnPwigfYVDGUOJzfMRVqQvSauIT36Ya0wedmSYMI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FM4HfBSQXCoW6b+JSLc86didjMSV/3BLaHgSEJqrhV8D7TmpHyErcmrTCrpv4yjETScacel3Pa2hYctnqC9mU5ECqPOZssCayDdu1yZiliuBkVOv2VC4XSYasePvUMU0tqDDuZOgKDkMNtXGUDGb9PsztUJnVNyXV+q/gqbKcp8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=LSTHUvZ1; arc=none smtp.client-ip=115.124.30.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="LSTHUvZ1" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1736139551; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=0oefN+xu13nE8jpyMKiHLPBwh/n+XfBGQdSn8o6rKB4=; b=LSTHUvZ1ZaS6ltpt1Lnm80tLIu4UoPACmEK/Qg9FxfxowcQ+qxf279PENrX4r4knmyJH8mhnRrLw1hulFQGk7d2vy3y5M76c27+YA8fa0P203PEAdhfJLFIbEe6AY2hve7xPpbV6N70Tod/zmu/g/k41eOCmWwgV2mJJVhWqSJk= Received: from 30.74.144.118(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WN-XEjN_1736139549 cluster:ay36) by smtp.aliyun-inc.com; Mon, 06 Jan 2025 12:59:10 +0800 Message-ID: Date: Mon, 6 Jan 2025 12:59:09 +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 v2] mm: shmem: skip swapcache for swapin of synchronous swap device To: Matthew Wilcox Cc: akpm@linux-foundation.org, hughd@google.com, david@redhat.com, wangkefeng.wang@huawei.com, kasong@tencent.com, ying.huang@linux.alibaba.com, 21cnbao@gmail.com, ryan.roberts@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <04997e54c276eff40a6119a90d36a4e71aade89c.1735806921.git.baolin.wang@linux.alibaba.com> <8344980d-4c22-4694-9a76-2e5a7ada50cb@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025/1/6 12:07, Matthew Wilcox wrote: > On Mon, Jan 06, 2025 at 11:46:04AM +0800, Baolin Wang wrote: >> On 2025/1/2 21:10, Matthew Wilcox wrote: >>> On Thu, Jan 02, 2025 at 04:40:17PM +0800, Baolin Wang wrote: >>>> With fast swap devices (such as zram), swapin latency is crucial to applications. >>>> For shmem swapin, similar to anonymous memory swapin, we can skip the swapcache >>>> operation to improve swapin latency. >>> >>> OK, but now we have more complexity. Why can't we always skip the >>> swapcache on swapin? >> >> Skipping swapcache is used to swap-in shmem large folios, avoiding the large >> folios being split. Meanwhile, since the IO latency of syncing swap devices >> is relatively small, it won't cause the IO latency amplification issue. >> >> But for async swap devices, if we swap-in the large folio one-time, I am >> afraid the IO latency can be amplified. And I remember we still haven't >> reached an agreement here[1], so let's step by step and start with the sync >> swap devices first. > > Regardless of whether we choose to swap-in an order-0 or a large folio, > my point is that we should always do it to the pagecache rather than the > swap cache. IMO, this would miss the swap readahead algorithm in the swap case, which can benefit the order-0 swap-in. We need more work to ensure that skipping swapcache is helpful for all cases, which is why I'm starting with sync swap devices first.