From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 7D4DB199EA3 for ; Mon, 6 Jan 2025 03:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736135172; cv=none; b=g07s4Zo6iVgCYGZp5YwK00L9oUbEiuOY7nU+DiVxtiMIjkA/+NOoVrQ8mMzeUDCfnKguzt5JJdvPFQ0ev6CwIk662/uVO0t3aBAhgPoCo+A/i6ei3QfkkTVeaBv044GGFv4ZANJKhwFrjgvBc2Q1Vplb/RV4A0tPXbSxvHok6yo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736135172; c=relaxed/simple; bh=NTedZrTylrgMn8f6/o86C5Z5mwmfTDKYCzZgj1mhsyw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HsuNkEtFdwxiG+PPLxNP6qOeDDbTaIEtTdAYTzRpv13aSzYx4D3x2rSpo8e1U2AUz4nEt11B5psB5uAu0gEQ6UTUAwqyzkInY0WQZ+DJG1oTqEkbf9iIerE6BBiD3spx6cganwlAER83D+q6bKUHtwFSOEzRjwg0KorU4lA9S8M= 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=w6Qmlk3u; arc=none smtp.client-ip=115.124.30.131 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="w6Qmlk3u" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1736135167; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=eFVDdwh8ELw0jbV5AFUuI15hDYlOiaItXRnpE5I9tN4=; b=w6Qmlk3u3oG9MniwpAA6BpCN6MKmlb4VZWP4Pd9oponZ+5ENE6r254v9pi1k/wa86DHaaE1hVNvmDNqj9Plpy4p9zmx6JdPj+htvUKxGGfnFvvsu1DgLluMOV25gswOKiD0EDIZAmhaQZ1JB1Fp/lBLFuWPCaBYRwkFkNqzjaIg= Received: from 30.74.144.118(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WN-7OB6_1736135165 cluster:ay36) by smtp.aliyun-inc.com; Mon, 06 Jan 2025 11:46:05 +0800 Message-ID: <8344980d-4c22-4694-9a76-2e5a7ada50cb@linux.alibaba.com> Date: Mon, 6 Jan 2025 11:46:04 +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> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. [1] https://lore.kernel.org/linux-mm/874j7zfqkk.fsf@yhuang6-desk2.ccr.corp.intel.com/ (Actually, I think we can always skip the > swapcache on swapout too, but that's a different matter). Good suggestion. I will have a detail look. >> +static struct folio *shmem_swap_alloc_folio(struct inode *inode, struct vm_area_struct *vma, >> + pgoff_t index, swp_entry_t entry, int order, gfp_t gfp) > > Please wrap at 80 columns and use two tabs for indenting subsequent > lines. ie: > > static struct folio *shmem_swap_alloc_folio(struct inode *inode, > struct vm_area_struct *vma, pgoff_t index, swp_entry_t entry, > int order, gfp_t gfp) Sure. Thanks.