From patchwork Tue May 21 11:03:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13669301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE42BC25B7A for ; Tue, 21 May 2024 11:03:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34BC86B0095; Tue, 21 May 2024 07:03:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ADE76B0096; Tue, 21 May 2024 07:03:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D8EE6B009A; Tue, 21 May 2024 07:03:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D974A6B0095 for ; Tue, 21 May 2024 07:03:39 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 91447A1175 for ; Tue, 21 May 2024 11:03:39 +0000 (UTC) X-FDA: 82142117358.25.37D39AB Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf29.hostedemail.com (Postfix) with ESMTP id 7F279120019 for ; Tue, 21 May 2024 11:03:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=lz3wmb9h; spf=pass (imf29.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716289417; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=emwz+iI9NQ7GxFXPBlPImuiv2PaM3+Taa8lvRwiumnM=; b=3+TL7LCauXkWOW5DUwOlrafE5jHy+U7LxwS9rLaZB5qkHbleCO4O6lkhnd9i1MNraN/FYX z02C81k/V8MoC6OQHtQko/xWcLvHOVQWPMAGT9HYftWp+dINinnOb4GwVQo7kHMafGEyZW oF5vuvoIgK0jkI6/0bKFL7WYcobGhtM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=lz3wmb9h; spf=pass (imf29.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716289417; a=rsa-sha256; cv=none; b=R2B39GyVCZksU9KQvXuT39AwoaIVJvUskPj5C7W8iugAsip7Y+KP/9a9y/yY1NRflkSbZD 2AB511oPafp4X9cFrIfL1T1fr4sFb+dpjXXIChua/KClc97cYj+Kx7hTdpfUKUNw4QQdsR N8zx+m5Cmzt7n1YxVL1GzWNiQ9mrD2I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1716289414; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=emwz+iI9NQ7GxFXPBlPImuiv2PaM3+Taa8lvRwiumnM=; b=lz3wmb9hM7NQm3xqYf8LPwVLZmpLvXu3uuGv0pvPh9RnGTU8FhSIHjQeHOmBJyr7IWGr9cAraPwBnK7LvvMbuxJNxcDCh0XiuLweDjD+LUCfhZ1XFVja4BLLP45UjsWr04fBiQEtCodoi18gUa21KVDxK1jeTH4cGU24+EPeKfg= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033022160150;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0W6xl94l_1716289411; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W6xl94l_1716289411) by smtp.aliyun-inc.com; Tue, 21 May 2024 19:03:33 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, ioworker0@gmail.com, hrisl@kernel.org, p.raghav@samsung.com, da.gomez@samsung.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/8] mm: vmscan: add validation before spliting shmem large folio Date: Tue, 21 May 2024 19:03:12 +0800 Message-Id: <5c919e5002739d2f396918d11bde5711d4ae8182.1716285099.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: 4e6ocxcupucqfts4ou1e1h9n4fic68wa X-Rspamd-Queue-Id: 7F279120019 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716289417-713021 X-HE-Meta: U2FsdGVkX18WpNjfuc1gVIjy+KexlfMjhz12AGGu6o+SQlCEKRnf49/SGitqYBCNfMXj9eN3ldFDfgXrK1BhCZLFGP1LeQuJEVIPzS36ZbS2rlwPhb9SQ3f2ANQ0G/CYMoEsncw6PCbWXcgZ1IhCWvzWl495g+2X8AiD8hWXlCmvROcXKhAwuRNt/oG0aK+oxmdsScZE/lGg32OtSkiaxDUNaBrtxXDZ2IzJnWrui2Idfe4DT7DnYXR+QPCmPdpciHs5FqRVz0rwJzAuapPCd9iO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@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add swap available space validation before spliting shmem large folio to avoid redundant split, since we can not write shmem folio to the swap device in this case. Signed-off-by: Baolin Wang --- mm/vmscan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6981a71c8ef0..bf11c0cbf12e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1252,6 +1252,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, } } else if (folio_test_swapbacked(folio) && folio_test_large(folio)) { + + /* + * Do not split shmem folio if no swap memory + * available. + */ + if (!total_swap_pages) + goto activate_locked; + /* Split shmem folio */ if (split_folio_to_list(folio, folio_list)) goto keep_locked;