Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp245249lqp; Tue, 11 Jun 2024 23:23:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXdDGU2/4DVe9HQ7v4tppato9QxB+hGUxmZjzOPqY9kpofmbZHRHIZauvucQuGlbxQM9goUg51Ke9qdfkO8yCvGUQv9yJ+cA2iLVXEYg== X-Google-Smtp-Source: AGHT+IFLDjp1ZNpGHh5Lc/pS3ECUazFT7VISckVE7XOtVJ+jR8ZSl0z2nHjLHxJecEqkOjAuRvgs X-Received: by 2002:a17:902:d491:b0:1f7:1b97:e911 with SMTP id d9443c01a7336-1f83b517487mr11305185ad.2.1718173411837; Tue, 11 Jun 2024 23:23:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718173411; cv=pass; d=google.com; s=arc-20160816; b=kIUR6QSavGptb6HooXA2RRjFyIBOgsdho52WH5QPgoLjpXCyVL9OYZeA6IL9A7Qvbr WeX/LvC/yd0H4AQgYf4U0gSGrv16tXNtp3t/K439q8SvvbFK6/f0BtD64/50xLAcPZ0x sIzbyBblRDX81Dm8gtCAQDB8RkQr+k/+NBQfwWx001pJMediTqxuLm/9ZXZ5tthuW7yN EkXhIbg+KdwCPZ4M4UE77wVK2ncVkcV1R7hsgUr30WoDhKS0KPX10AAPurd/0qQtJbu5 jvK2lbKiUtUSZNExpmUJHmalFTQ6gUOBtP3x59X8CiiOmF8RWCDwjx9GLmlL+p8o5ksP yK6Q== 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:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=VkbxeyTbzZHZmW5pIOy78DIOXXvghz5goTacRzjkGcY=; fh=/wYRKHO/vp65D6vHFUPDZc4BjMDjY3QWn+DXd2pLPHM=; b=AJHZV84K1jZ8974xLu+IELWouivjYsjvWs2qY+FHe0MLBw+jlneMj3Cq9fxW7+qjNr 8lc3p0RnR7VTVegwSqZEuUZCTzSHb2Cj8cXxooYM9l5YN+4zdLxpaEYmKLHFFidTcrzs dZCz9jOFadd0iTLDrWZcwVcgyWjNGRoT53zJr5oGDsFDR4PFEIUkTZhlTsVxMeRVMOIf +Y13qM9XOkIW+YWEGhMfyW0PWKOoJEfkbISc4eTql+IpWP0pe5wyCQ+ylJWtAS435O7N t5/AyMTa7+dUg5XMfOAsbZLlM01AEVEdFepgQyBfBW+zUClOZT8i7qV5MoseU9FSm28u awBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=xZun7ONV; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-210972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f7e32ff342si13099245ad.533.2024.06.11.23.23.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 23:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=xZun7ONV; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-210972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B951C284EAF for ; Wed, 12 Jun 2024 06:23:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1BD0167D8E; Wed, 12 Jun 2024 06:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="xZun7ONV" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 75A2D13CAA7 for ; Wed, 12 Jun 2024 06:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718173403; cv=none; b=DxJaCrPcuBb6SKDwQA2VzCGSerfgpSFAcnTcFPZllFnMMR4UYzhtupv41dVmxi/7eKoFcUh7znKIn+fkKHnnlDC26auxqWL+8NnAK3qs2sf/s22N3lPyhPORAOLMF27Xqoqi6CucAzYQ4Aq7CfCmn2sCrdkVcZvsnUvMM4h8748= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718173403; c=relaxed/simple; bh=icd9nxjBubTTVN7BCWPA9XGhyGP3xyxo01FV3QQfzoQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ToRGzowA3dK3ZVvhadHMQmJ7C476P5LZ/R8SZpCx5+cCLhZFK7RN/kbULOz2S6cwDBqSOg77s3hPb6BVyrbAK16/Td1ANWcYwDpBOxFPNAS8KmcfiyPu2BaFMS5WY2DTKrXtTn9KJpsHLwi69cshvc1PjsPf+DHn4XvixwMo7rE= 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=xZun7ONV; arc=none smtp.client-ip=115.124.30.124 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 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718173398; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=VkbxeyTbzZHZmW5pIOy78DIOXXvghz5goTacRzjkGcY=; b=xZun7ONVSp59YHlaF88XlpNhvWvx/mKEtjYh0DtNHEnG8liZK5fDiONRvL6q5kop37pXvLyRsjefAGf5CYStfFI/p7O4D+773IYlMrvwVK5QjfdgY+6d+dA89bxHCZ061BFx4Z0a7O8maFVRYtQ1ttftealY+/zXVBj435jTUlI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W8J9Tpa_1718173396; Received: from 30.97.56.60(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W8J9Tpa_1718173396) by smtp.aliyun-inc.com; Wed, 12 Jun 2024 14:23:17 +0800 Message-ID: <3d8087e4-ff84-48cc-823a-a6ce2a3c76b4@linux.alibaba.com> Date: Wed, 12 Jun 2024 14:23:13 +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 0/7] support large folio swap-out and swap-in for shmem To: Hugh Dickins Cc: akpm@linux-foundation.org, willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, chrisl@kernel.org, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, ioworker0@gmail.com, da.gomez@samsung.com, p.raghav@samsung.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <7477de0e-e5bb-529d-e2c0-cabd0d39fb5c@google.com> From: Baolin Wang In-Reply-To: <7477de0e-e5bb-529d-e2c0-cabd0d39fb5c@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Hugh, On 2024/6/12 13:46, Hugh Dickins wrote: > On Thu, 6 Jun 2024, Baolin Wang wrote: > >> Shmem will support large folio allocation [1] [2] to get a better performance, >> however, the memory reclaim still splits the precious large folios when trying >> to swap-out shmem, which may lead to the memory fragmentation issue and can not >> take advantage of the large folio for shmeme. >> >> Moreover, the swap code already supports for swapping out large folio without >> split, and large folio swap-in[3] series is queued into mm-unstable branch. >> Hence this patch set also supports the large folio swap-out and swap-in for >> shmem. >> >> [1] https://lore.kernel.org/all/cover.1717495894.git.baolin.wang@linux.alibaba.com/ >> [2] https://lore.kernel.org/all/20240515055719.32577-1-da.gomez@samsung.com/ >> [3] https://lore.kernel.org/all/20240508224040.190469-6-21cnbao@gmail.com/T/ >> >> Changes from RFC: >> - Rebased to the latest mm-unstable. >> - Drop the counter name fixing patch, which was queued into mm-hotfixes-stable >> branch. >> >> Baolin Wang (7): >> mm: vmscan: add validation before spliting shmem large folio >> mm: swap: extend swap_shmem_alloc() to support batch SWAP_MAP_SHMEM >> flag setting >> mm: shmem: support large folio allocation for shmem_replace_folio() >> mm: shmem: extend shmem_partial_swap_usage() to support large folio >> swap >> mm: add new 'orders' parameter for find_get_entries() and >> find_lock_entries() >> mm: shmem: use swap_free_nr() to free shmem swap entries >> mm: shmem: support large folio swap out >> >> drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 1 + >> include/linux/swap.h | 4 +- >> include/linux/writeback.h | 1 + >> mm/filemap.c | 27 ++++++- >> mm/internal.h | 4 +- >> mm/shmem.c | 58 ++++++++------ >> mm/swapfile.c | 98 ++++++++++++----------- >> mm/truncate.c | 8 +- >> mm/vmscan.c | 22 ++++- >> 9 files changed, 140 insertions(+), 83 deletions(-) > > I wanted to have some tests running, while looking through these > and your shmem mTHP patches; but I wasted too much time on that by > applying these on top and hitting crash, OOMs and dreadful thrashing - > testing did not get very far at all. Thanks for testing. I am sorry I haven't found the issues with my testing. > Perhaps all easily fixed, but I don't have more time to spend on it, > and think this series cannot expect to go into 6.11: I'll have another > try with it next cycle. > > I really must turn my attention to your shmem mTHP series: no doubt > I'll have minor adjustments to ask there - but several other people > are also waiting for me to respond (or given up on me completely). Sure. Thanks. > > The little crash fix needed in this series appears to be: > > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -2053,7 +2053,8 @@ static int shmem_swapin_folio(struct ino > goto failed; > } > > - error = shmem_add_to_page_cache(folio, mapping, index, > + error = shmem_add_to_page_cache(folio, mapping, > + round_down(index, nr_pages), > swp_to_radix_entry(swap), gfp); > if (error) > goto failed; Good catch. I missed this. > Then the OOMs and dreadful thrashing are due to refcount confusion: > I did not even glance at these patches to work out what's wanted, > but a printk in __remove_mapping() showed that folio->_refcount was > 1024 where 513 was expected, so reclaim was freeing none of them. I will look at this issue and continue to do more tesing before sending out new version. Thanks.