From patchwork Fri Sep 20 12:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang Gao X-Patchwork-Id: 13808500 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 B8C24C78830 for ; Fri, 20 Sep 2024 12:20:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CA9B6B0082; Fri, 20 Sep 2024 08:20:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27A026B0083; Fri, 20 Sep 2024 08:20:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 141946B0085; Fri, 20 Sep 2024 08:20:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E43E76B0082 for ; Fri, 20 Sep 2024 08:20:39 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 94E0EA8EAD for ; Fri, 20 Sep 2024 12:20:39 +0000 (UTC) X-FDA: 82585024998.04.38563C0 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf29.hostedemail.com (Postfix) with ESMTP id C452012000E for ; Fri, 20 Sep 2024 12:20:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rq2G0YAz; spf=pass (imf29.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=gxxa03070307@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726834723; 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:references:dkim-signature; bh=uBmgJ3E+zJEFPhajcCAnbmCn511pKS8K43xQBt9qbMc=; b=01ALWyR8QLXZsC5aEeQLKLAmeWuVz2/tO6UhNCQEP8ZIy6+y5ihnRzB6SHPpqQweJ3nrMz nbjwantfZs5d4ABUMb5ctl3+xD4BlsNd7KzXou8Owr5H0lVKEiJkmIN8DaqR0Hh+sSUbXJ +XgX1BOBwJupnNiAZ/zsmp4t43tOPys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726834723; a=rsa-sha256; cv=none; b=4tPysbkRNNFiPizYm42WQAaNj7iZEfLxr97mkNblgPUP65TipyehzQ+QJto8E+Fzm0y6Mg R58UWkr8wy4FpZGYwWe79Xc1jnPqfHjY3yXTqbt375djGB+++xDrYMMlXYGp1zC6410Peq K44c0c8Q+j+XgfzMjBrrOhaLNmLsxrk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rq2G0YAz; spf=pass (imf29.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=gxxa03070307@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-718d704704aso1623262b3a.3 for ; Fri, 20 Sep 2024 05:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726834836; x=1727439636; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uBmgJ3E+zJEFPhajcCAnbmCn511pKS8K43xQBt9qbMc=; b=Rq2G0YAzd6fjktRBxWVexgBgCv4kGxZMC9xH4vQSLotTCD9z1rEX7O/M8ym2w7a//O RXgH6avwW3jqYXem2nvGI7cXrduLc68rLTxGG59HeGWPJGqrwtWADayZx5V/m2QOehwI m5gBgrl2xR6IxNBAjKX4XKIiGdPiRDVq3DJLxeRYTS0nCtjStAQrnUTqDoCW9qXzGFxy SXpZUDXSsxQH94uzYAVuiQE0QC7hW8umxAk2ylUifAtDUfgIpQ3KpS5rIaH2QsDP9dM7 RO2+Eonn/0cWBqPuZMe0GSkSwtfXQRWLyMNrdFJLIoZvuF4UleBRAYtCp6u+SHNeHG2I WpJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726834836; x=1727439636; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uBmgJ3E+zJEFPhajcCAnbmCn511pKS8K43xQBt9qbMc=; b=M+fxIX2evmxaWlC1ixZZKCi40ylzHHR5N72IleVyyfEKrcggVs4ny70/0aUbPvqJxf J3IH67XdazKzP5WZr6DbbGhrM5CC/BZeZRqQ5ji9YEw4EgdOG2qinXkCcqvOxvpNY8+p ygv/tH10S3Hb4eUn3oVTd0RJIaMg+dbmXJtX2BeleDdgzsTVuXO+ybLey+YsT0aAXK/o OVtsl3NlOhJXUmdXwMHfQM1bGXpCS/LZjAAzxUYksRt/psymx0AMyPMII7EAW5MlpuDY U/Q6VRedytK3rAmuIyf3dR0wgBONs+tZNco0FinemLPxVhrpOigrsg+m1up+RiLFy4mR TCZg== X-Gm-Message-State: AOJu0YyKsdHGRix8caIrMvvM/SoZ9j/IjI05ZUxRZEMId09IjGNFDWNb 870oavSH4/lUyFeZ5RSHa0azonVcdgMtN7nLqh6cICrPiFt1kX4H X-Google-Smtp-Source: AGHT+IGk1cGR5y1+GjjZv3Z8cfFvB8ZNrHFiohP/FG6vRNw1JdrLfQ1aw74lxhXZDqTOMoWNX8Q1BQ== X-Received: by 2002:a05:6a21:e8b:b0:1cc:e43e:3a01 with SMTP id adf61e73a8af0-1d30a9be470mr4609792637.33.1726834836430; Fri, 20 Sep 2024 05:20:36 -0700 (PDT) Received: from xiaoa.mioffice.cn ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71944bc8310sm9761927b3a.189.2024.09.20.05.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 05:20:35 -0700 (PDT) From: Xiang Gao To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, gaoxiang17 Subject: [PATCH] mm/page_alloc: Add some detailed comments in can_steal_fallback Date: Fri, 20 Sep 2024 20:20:30 +0800 Message-Id: <20240920122030.159751-1-gxxa03070307@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: 5zgen1jc4zqjwtgxybxj9s55uzfp4szw X-Rspamd-Queue-Id: C452012000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1726834837-200179 X-HE-Meta: U2FsdGVkX19ygLTgBPRZAI13bVifgoXv1AO2VNt0+NW7wPJa0Y7hSXksxd6VGWgWCVPVBRWlrzBXtxQIGbK7wGxu6I4tSsXr27azN+AlyVHCH6TSffCKciVQVD5HOEKQJxdSGbqcfIsQk+Ibs5VpzUdCdC1chgfssWFHyecKc3KVEQMkImeudjiKuPHAwS7ai+GoXq6xdNZuh75Z4ua3bitsnrmb/CcTDvqs1SB8NptuIZTm8o2XzwmjPmHHpvR2E8l1YSsuRmqL7T/PJ6j1B7ZRXm3KE7awi/CLhH8uiZJM1W+CO49E6+W+HcFwYlruTfiv/HmrwAvynZ3/5jx1GZd7qoUSS9IXuul3zsEaFxzthL5cKe0JhPDJ531F4p7lJeGl3JX4hhf890HEk/p50plbHt5WapKU71qTXJx46VihbXUexXLY/Ppvun/TFg5PbtY3YPY4so1ZLOrhVqENzfGbKJSLHJPt2JezWMBR2LitNnrc6I5kHtjGIei3ENXEBu+KUfMiqy6eDUOb8GjfDmOhMcbwZbcnogVT6yYCSm23k+fqzuRSvxQM/F9hZEf0Ro+eWruQmD8xfLRJGFL45SFTwx4HG8Sn26dj5K9f/2faEkbKOZsVdTtWi/gSzVUMwqENyT43JjxfbdkUEB1M7kzih7k8t9Bc2kc/8yq4nHJGq2oZhpWXm+gcXaZZVclFN3hZXMebeV6Z7uBM9G+cksE4Mcu+Xb/A4jeF5FnAcQecYXugNpvs6//6eE0cCMUyv7jxD9c/q0h+I85Q1HGzuKfr4pGsC/UZWUkChMm2GhA3BuYck2UptKeITgy7EQGUxAikVGBSiw+v5JqhmExsIlvLAwC4MfoitStI1wRk8wqTz8VM120DbGyYN66W+HaUNN+56pXPw7nMxzPJ5Sz7oMZiKcNeXUNaVu/qxYJePcIGT33HO2zWNP+92wY3dum0NSfi9GzhPXYXY7CUaMV 8J5LKVcF KUdBGnhYuTJz10CJyVsH47McRk/6HYXIVEK0KsTe8jFfKTpt1AAkZQ0D6lT4cXBvYcrnjS0lbYQmzWhWPm+WzDhvcFjsByc5htz2AgRaj8eFt+S8Wft/Lk5WFTuZCosCocAXLiotRpivuVeiwszcmSF9c1/JgM41nbYJR1f9vERyyjV1GN+f3EtKsE9b27hFUEGs6aRX2Bo9B+4MGbj/pKcNgZ17k7Ax9CNqNaQkDtJNo+qVghL6zI/Lgy48ru8fduoo+6nNokRDQ0U+ee2Z1TpeMQ48dacvvrLQw9bbkSrmTnpWaCL4xvyx33YiDbw9rS2IKH+H8vpjo6foZ4xC0/k7mPLkxqfMu9L7iOiuqtf2I3663fkSmgjpTknJCFyfvYZikO4uxxzRqkrg6N7oiLMRNfajch144LGauYwLMb5DF6w4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.211813, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: gaoxiang17 Signed-off-by: gaoxiang17 --- mm/page_alloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0aefae4a26b2..8b0634d1728b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1818,6 +1818,13 @@ static bool can_steal_fallback(unsigned int order, int start_mt) if (order >= pageblock_order) return true; + /* + * movable pages won't cause permanent fragmentation, so when you alloc small pages, + * you just need to temporarily steal unmovable or reclaimable pages that are closest + * to the request size. After a while, memory compact may occur to form large contiguous + * pages, and the next movable allocation may not need to steal. Unmovable and reclaimable + * allocation need to actually steal pages. + */ if (order >= pageblock_order / 2 || start_mt == MIGRATE_RECLAIMABLE || start_mt == MIGRATE_UNMOVABLE ||