Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp271453lqb; Thu, 14 Mar 2024 10:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsvAUXjj0mwKeFQG3T2g6zSmr/ZTCMrkkP7IJJTfuz4OR4KFG4pdL+votViwqmgFgqgyfNmpfnhtWYkAs078liB9JacEnXX5yJAzpZcA== X-Google-Smtp-Source: AGHT+IEErqQJn+bSp10R7WmEISxpAqo+yW+ZjOVX065+wgNPqw5jTkdala8BC3Nj5sjo086op+a6 X-Received: by 2002:a05:6a20:2451:b0:1a3:4670:e8ec with SMTP id t17-20020a056a20245100b001a34670e8ecmr1872444pzc.18.1710438488119; Thu, 14 Mar 2024 10:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710438488; cv=pass; d=google.com; s=arc-20160816; b=ObnTfVL4dStwOjSneUNmzPFsvbovukET1xfPu17fIC3bgVjfxmFo9at/Ksni8LXfjg O0BA8o1LSyyRB4/7nRvzFtqLjKo0ThYUEBF5YjVC4LAB6WAOPjgEAs0BkLeG13WqDgEP uwPeZPfVifpv37WqCqQQ7j+q0YsDgk59b2LJlYIjy+JEVunt5JVVl2Ta0gbJwt6ZBP9k PNP+K5WV9XreC7u9vcibbaJIvK3pSPQg4hD8VEYNJ3BG968ATW1KyyEW4JqPo8LvdYiM LAw3oKtQlKheeHF9AXzC1MQ1aUBeIx0ABsAJPzBu0y7zbZjImkaM92mH9H9hj7zEzsqH W4eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=m+JV3A7zu6nIaIvNDYv5nSo/ckyKnBKjeigqrs00bqQ=; fh=638gt/OA+schbm5v5N/M4Rl6BZuAkiYjW1gD5rIOoI0=; b=bUwS0HpsgCOZP0+Xtt+VhjGYkihRPe7zJed7B3iUUIxZMEHcdHJnNJHKs8MEoqx+92 zuq+VgzJW58J196+X2nByioyC9GygaAeeRGAD4uw5mLRbsx2/Ozw+UAYgRPo3X8ZN/2m +LiEDDqMxcnvFHuf8VRyeHb0F8OaRkCy8KbI1sOGfl2q1BJV4oUDu4OxSLBcLbaOvJaD w9UZHqZ5+D1+OgNWajpL0y8K34rXx4FZh1Xz/8toq680ReTTvnD7a02STlum+v/cqfiu y3f+CusDzMd1PGSJ1cx8LCS8W8PQJvR4XV2ZPoIqM6N5R1bPNEHdHHfanHZC3J2V15sa KWGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oZSV25oT; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-103634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v24-20020aa78518000000b006e613ec716dsi1868599pfn.143.2024.03.14.10.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 10:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oZSV25oT; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-103634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 B3F68283CDF for ; Thu, 14 Mar 2024 17:48:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F1DA74BEC; Thu, 14 Mar 2024 17:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oZSV25oT" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FF5974297 for ; Thu, 14 Mar 2024 17:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710438482; cv=none; b=sR80CFYnAxQ4AQ4SG+SUjGkX51pgWBUGGTlCt+MHc756BjFlI9MAJhj2DxCATh/VEs+BEQ35kms2J57AVkCIgQUWQM0Ln03qL4oJ7VYb8sTJKOpXDuWpd7Bu/5vwdQNa/libwU99a0SgAsrUzB/l8Qfc52FMMcHKzCWlryo7WAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710438482; c=relaxed/simple; bh=q1LPenCDNdcBSutkq0Nq6yhy0rl+ccCriK1caPK76QY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=eiIZB/qgofHFmSH8kMCRmQf7KODjN46MKQ7oYfEh0NcTN9HUfTZVbIgtKgvfFl7foqX40AkNxm5+7PsCvk1CBst9MDA5q4qxLFypp1L1BsvkziMouQrftXsdzYfC9QjeM234l4mnLHdLtjVDILqSzlqSyEU2MwL9VoAR6n9HgOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oZSV25oT; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-413f8c8192eso9005e9.0 for ; Thu, 14 Mar 2024 10:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710438478; x=1711043278; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=m+JV3A7zu6nIaIvNDYv5nSo/ckyKnBKjeigqrs00bqQ=; b=oZSV25oTVsLsoeBrHTH7Ubbt1KQPk/T0pAusGoQ7KdS2fDfVkaQ5pwXGDcDqS6SFFQ 6Qvh0OdagffHuZ3E32/bP+z1/xRb8Jd8S/wJPqtVfyp3McH53dVz6BSlhWqVJiDdR9GE XySeCL/hAEy/fd67FsHWVjWoQjcoIvT8L3GWTjApqJSN829JGRaRdSQFPAHbg6YTEj6o BefKGLxEVBN96LS8s4cY+8qdCWXc/tFrCQ+6ihrimNfN11ptXT3jwdeiB2RUNrfOhS3m yValG1vXiRlmBh0ihvGchg1tN3U0Rzw2JwbR4TZJ4+ofoQJ+lnMaIP6grTu9QfNAYIrM 639A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710438478; x=1711043278; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m+JV3A7zu6nIaIvNDYv5nSo/ckyKnBKjeigqrs00bqQ=; b=uSO2OMCaSr/2ivJ1XNVKnMGyn1Rc45BiPrnpvOiyzPURO0VJhgqsxIgOCtjK6Qxvx1 M8zZyfwsOsPKWxy43ClQUroA/ny1A6TmQ2pDxtiAB9z9YTW3BOPmq2DSb27P2tzQJ5Jq ZCBqxjHl5wQFpzSF6osEqcUQCzW0Xy2cO2kuUrqjyx68UeOqSS9+QyXyWfrEaFWUbDOA pN0Rz4yY+vrixkEI8SCL31vgA0MMEttACikgD5ABIAKG7Xw52es9OI8OLkVPVyZZvY0i b+oocfMeFgIWlEst2JTul6QgULjgLTV0DJmViDTNEcn1KB04B8RnuudD+SFo+XNwMFmx cA/Q== X-Forwarded-Encrypted: i=1; AJvYcCVtIrcEpjRrKDu5qipw/r/1lfaC4RljLrvDClmjOxv9tfffvaLLhJDfJU1kN8Rob+g0QwF3GNT5dUFEKGWvbqCeHabHwX4eD2frrtWS X-Gm-Message-State: AOJu0Yzav1P7lKAOXSe6qb3abU+E2i9SOdoHIAgXHjJruE7oru7Azpf1 QU95DANhhIk7UDj1AzZP+ZvswbeNufkyvBm7gLWdH6rRV/DoIrsP9+STnWxWPN+2Y5aKKdmGgh1 1wM5W/d/UZXw8rMPGHyJ0Qz4xWnjyaB2T3QfU X-Received: by 2002:a05:600c:1e03:b0:413:ef8f:751a with SMTP id ay3-20020a05600c1e0300b00413ef8f751amr219687wmb.2.1710438478385; Thu, 14 Mar 2024 10:47:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240314141516.31747-1-liuhailong@oppo.com> In-Reply-To: <20240314141516.31747-1-liuhailong@oppo.com> From: Yu Zhao Date: Thu, 14 Mar 2024 13:47:20 -0400 Message-ID: Subject: Re: [PATCH] Revert "mm: skip CMA pages when they are not available" To: liuhailong@oppo.com Cc: akpm@linux-foundation.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, surenb@google.com, zhaoyang.huang@unisoc.com, Charan Teja Kalla Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 14, 2024 at 10:15=E2=80=AFAM wrote: > > From: "Hailong.Liu" > > This reverts commit 5da226dbfce3a2f44978c2c7cf88166e69a6788b. > > patch may cause system not responding. if cma pages is large in lru_list > and system is in lowmemory, many tasks would enter direct reclaim and was= te > cpu time to isolate and return. Test this patch on android-5.15 device > and tasks call stack as below. > > Task name: UsbFfs-worker [affinity: 0xff] pid: 3374 cpu: 7 prio: 120 star= t: ffffff8897a35c80 > state: 0x0[R] exit_state: 0x0 stack base: 0xffffffc01eaa0000 > Last_enqueued_ts: 0.000000000 Last_sleep_ts: 0.000000000 > Stack: > [] __switch_to+0x180 > [] __schedule+0x4dc > [] preempt_schedule+0x5c > [] _raw_spin_unlock_irq+0x54 > [] shrink_inactive_list+0x1d0 > [] shrink_lruvec+0x1bc > [] shrink_node_memcgs+0x184 > [] shrink_node+0x2d0 > [] shrink_zones+0x14c > [] do_try_to_free_pages+0xe8 > [] try_to_free_pages+0x2e0 > [] __alloc_pages_direct_reclaim+0x84 > [] __alloc_pages_slowpath+0x4d0 > [] __alloc_pages_nodemask[jt]+0x124 > [] __vmalloc_area_node+0x188 > [] __vmalloc_node+0x148 > [] vmalloc+0x4c > [] ffs_epfile_io+0x258 > [] kretprobe_trampoline[jt]+0x0 > [] kretprobe_trampoline[jt]+0x0 > [] __io_submit_one+0x1c0 > [] io_submit_one+0x88 > [] __do_sys_io_submit+0x178 > [] __arm64_sys_io_submit+0x20 > [] el0_svc_common.llvm.9961749221945255377+0xd0 > [] do_el0_svc+0x28 > [] el0_svc+0x14 > [] el0_sync_handler+0x88 > [] el0_sync+0x1b8 > > Task name: kthreadd [affinity: 0xff] pid: 2 cpu: 7 prio: 120 start: fffff= f87808c0000 > state: 0x0[R] exit_state: 0x0 stack base: 0xffffffc008078000 > Last_enqueued_ts: 0.000000000 Last_sleep_ts: 0.000000000 > Stack: > [] __switch_to+0x180 > [] __schedule+0x4dc > [] preempt_schedule+0x5c > [] _raw_spin_unlock_irq+0x54 > [] shrink_inactive_list+0x2cc > [] shrink_lruvec+0x1bc > [] shrink_node_memcgs+0x184 > [] shrink_node+0x2d0 > [] shrink_zones+0x14c > [] do_try_to_free_pages+0xe8 > [] try_to_free_pages+0x2e0 > [] __alloc_pages_direct_reclaim+0x84 > [] __alloc_pages_slowpath+0x4d0 > [] __alloc_pages_nodemask[jt]+0x124 > [] __vmalloc_area_node+0x188 > [] __vmalloc_node_range+0x88 > [] scs_alloc+0x1b8 > [] scs_prepare+0x20 > [] dup_task_struct+0xd4 > [] copy_process+0x144 > [] kernel_clone+0xb4 > [] kernel_thread+0x5c > [] kthreadd+0x184 > > without this patch, the tasks will reclaim cma pages and wakeup > oom-killer or not spin on cpus. > > Signed-off-by: Hailong.Liu > --- > mm/vmscan.c | 22 +--------------------- > 1 file changed, 1 insertion(+), 21 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 2fe4a11d63f4..197ddf62019f 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2261,25 +2261,6 @@ static __always_inline void update_lru_sizes(struc= t lruvec *lruvec, > > } > > -#ifdef CONFIG_CMA > -/* > - * It is waste of effort to scan and reclaim CMA pages if it is not avai= lable > - * for current allocation context. Kswapd can not be enrolled as it can = not > - * distinguish this scenario by using sc->gfp_mask =3D GFP_KERNEL > - */ > -static bool skip_cma(struct folio *folio, struct scan_control *sc) > -{ > - return !current_is_kswapd() && > - gfp_migratetype(sc->gfp_mask) !=3D MIGRATE_MOVABL= E && > - get_pageblock_migratetype(&folio->page) =3D=3D MI= GRATE_CMA; > -} > -#else > -static bool skip_cma(struct folio *folio, struct scan_control *sc) > -{ > - return false; > -} > -#endif > - NAK. +Charan Teja Kalla -- This can cause build errors when CONFIG_LRU_GEN=3Dy. If you plan to post a v2, please include a reproducer. Thanks. > /* > * Isolating page from the lruvec to fill in @dst list by nr_to_scan tim= es. > * > @@ -2326,8 +2307,7 @@ static unsigned long isolate_lru_folios(unsigned lo= ng nr_to_scan, > nr_pages =3D folio_nr_pages(folio); > total_scan +=3D nr_pages; > > - if (folio_zonenum(folio) > sc->reclaim_idx || > - skip_cma(folio, sc)) { > + if (folio_zonenum(folio) > sc->reclaim_idx) { > nr_skipped[folio_zonenum(folio)] +=3D nr_pages; > move_to =3D &folios_skipped; > goto move; > -- > 2.34.1 > >