From mboxrd@z Thu Jan 1 00:00:00 1970 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 11F2CC531DF for ; Thu, 22 Aug 2024 06:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 902616B0194; Thu, 22 Aug 2024 02:40:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B2346B0196; Thu, 22 Aug 2024 02:40:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A05E6B0199; Thu, 22 Aug 2024 02:40:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 59FDA6B0194 for ; Thu, 22 Aug 2024 02:40:05 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A3BE9141299 for ; Thu, 22 Aug 2024 06:40:04 +0000 (UTC) X-FDA: 82478931528.01.D3ACF30 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by imf19.hostedemail.com (Postfix) with ESMTP id D69D81A0002 for ; Thu, 22 Aug 2024 06:40:01 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Kxe2308q; spf=pass (imf19.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.167.43 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724308786; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XCVQDVF7en/QRnK1xIM7N8O/LMZFliQ8B1T6Dzt8Q7M=; b=1AP2kj9EL3W8UHYK58mSayG6hTA2LpXxByS0AxvmVcMwyZq+U3qTAtyn0hI1t3bY4VJy2y G0H8eegVdQi9Sm5QQyDh+YTGZJowoYmshBvqTBmpFVxdLl9YlmomiZmwJC23sLtu4DQ+Um vlCY55noAdH8MkbIcCSayAcshjqf3Gg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Kxe2308q; spf=pass (imf19.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.167.43 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724308786; a=rsa-sha256; cv=none; b=R8b5lPpF33tTFbyoMp4O15VEkRRUFii8stEsLZJtaDADzPxDNs/5Ard38yH9BXkm212T0s WCTMfg9Zw0T99HVliDnzMac5hzWrHaOUa5wua6I1Zah+95DRb5z+ApYtUnIpxxvKkq9Z1Q o/KjbDS+1lXbETbVI+DUAwhG7r9w2rM= Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5334c4cc17fso598375e87.2 for ; Wed, 21 Aug 2024 23:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1724308800; x=1724913600; darn=kvack.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=XCVQDVF7en/QRnK1xIM7N8O/LMZFliQ8B1T6Dzt8Q7M=; b=Kxe2308q9leHF0qKUk0kqUpeeiFfJ7eFBPwno7bSYrN+RpBcdkYGypBBhFDGfGXrVz LDHtnMxnDxt645+D+brn48zV74Wi/6E/T9ADK0Iy2XagVpRrxCiLdNicZfVYfS+u6Wxx GpfvmjoH0Gx0xeG0YMS2Sui5lFMksBugAjZLSy4lZErsAo78vX/pSa9LRr0Moyvobky9 YsCbggaNBLvWDN0zOAVay11Gwuf2IyYLozUDnN69+urfz6o/n2ETptolBaYTVJ1VlWJ/ 0getz9Y3jmoj6eCJITlvwy3B92iz4U1qZx+4mOz7jkMrzky68qolf5ZqA5MJzvzpr/S9 umxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724308800; x=1724913600; 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=XCVQDVF7en/QRnK1xIM7N8O/LMZFliQ8B1T6Dzt8Q7M=; b=l8/HhHAIfLJGRX8YihV3d22pS7UXnhpMCuV9SXC/z9k+tXIk1H8rfjbjCs5sy0dViL gnWmWEeBZ8yQ1d4UdLATASkndzGvzzzB17dScJJOKSZtQSv8ligtUpZytkeFuJdD4Zoq if1YO7oBgHihl3Zl5UUnB0noLDScmrhxR/U58lFf61iwsQBBsL02OIgB6Kn4PFlY0QbF TORYRkG3VgwTVurnzjy0A9udh/bQzWf9TcLz5/jG8RFT6uoVTvRWUvM/t8XsEaF7z6W7 RT4omz2uCsK5/98xYklt0PpO4JVCzqt7ojN/kALerXI7EMk0C0AFc+SfuLI/390+4xXe wcoQ== X-Forwarded-Encrypted: i=1; AJvYcCUfA4fXJ/H5IZY2uAVvRm6DlFlZt3EUXh8pWz3mCqHyXrlk3tcEY02QK5MI+kv9/QLqHBTqC7oD/Q==@kvack.org X-Gm-Message-State: AOJu0YzypliSvdTBYgsGkIl7nvkXB5KEZP46NmCM80/io+bkGWHOFGYe wXCpKNF5CYOAx9RaylKEjWMDNa4P6Oo6+e8v2DohG02eev47NUQPkl/mwBa+xdCsqoS/QgE98q0 GtrTl4VmEGyKFCOgFIoqdZqT8PfRCqZZrlE9S4A== X-Google-Smtp-Source: AGHT+IFY36eHWfAP1XynkkC+LNEHHDuQ2xKBZLWRjR5by5IXkqnZjQHoJe+94UuXASK12H/Wxn6CnMh6K/TR6iCztAI= X-Received: by 2002:a05:6512:3baa:b0:52c:e1cd:39b7 with SMTP id 2adb3069b0e04-53348564ff3mr3085882e87.5.1724308799509; Wed, 21 Aug 2024 23:39:59 -0700 (PDT) MIME-Version: 1.0 References: <20240821135900.2199983-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Zhongkun He Date: Thu, 22 Aug 2024 14:39:47 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm:page_alloc: fix the NULL ac->nodemask in __alloc_pages_slowpath() To: Michal Hocko Cc: akpm@linux-foundation.org, mgorman@techsingularity.net, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, lizefan.x@bytedance.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Stat-Signature: edwjk94a4upk64csw7h1obtz9oa8p5gr X-Rspamd-Queue-Id: D69D81A0002 X-Rspamd-Server: rspam11 X-HE-Tag: 1724308801-318544 X-HE-Meta: U2FsdGVkX1+k665uozWuYtOl9VVcAZbC7F7VnSUqTTh5Jw+h36ERy/pKhT5TPWEGJ5mu5gfaRwetq5exJkXgl9nCeJlFweLxGD9v/4NB+Tqtqd+0KE24V6Ooo0GTMrhT8R6fJB5PWmrlW6mz4rsZ/4naCQSJfPgMcsssmTFuKoNNBK+iSO57uRXFE3nHhzxyizuSJOfK+yyPjqcD5F0Xx0mg5xDksAR4M8xt5u9YFy+aav31DT7NI7D73PRLlBzh+zmTViZ01wim3mUbmrJlrFZ2Bc9trLxLqjBfkdrrVBL+AX67ibgR9u6DifYaKgbCJ37drAc8IeyCWc6MDEIXptE9IP36tEOTkTd6my5cD/UVkVGVAkTlAY5d9SKM289PvPjhVnAzQu+Mjto1/M+KRAPbVIbo0+WPx8HLUakhhoNqjHaFXaFbOHmsbHNK33pPjbEkKsaS+4wuxfvTaNeZQBmzGlj7lCfs2R54QceIzzrpN/Hsf55Kch318jRugqa4KyOfXH7c/QnDCOVz41vtmBQ5luOR0zdZT8OGP0e45YoyzH0WNm0GjLTEwAytCuYDoufEpV9VqeXuCKKO4n1It6DfJTmdlMfbAlCruc3bOVHMF/A6YF5LiTaoFKW4RShem2HTZ9cHNIrP4IQaJCDpWBJP7UoX8MIOKzO51SiQPvpTBjXnhXjyJ+lyq1Lj9gs30is8gLUNB319dtp+wsKKnPMEXY4eoRJtSgmmYUnkVMtihEjfB/BR9DVzgAgpzmGsAB4mU1HdiD3fNr/8Z+RaRqaB0I+0Ljl21LkkzUeNzPhWdgxtLjXgQk0vBYfa3cvZUOI75P6sJHOeWxVoqFecQC2Q5phNvZlmTZnGHjOB1bTZ4EXLo/iuMamYE/SP3bn1ucG1MNXPgSqUZqAmshy16UTbfme73GspoQ2mOWusqiGgobiRk9xn/PLsk0jjv4kOLV5HTj31zEMUGP+Uzuo It/jEYx1 kpRqPRPsl47WT/dpVNnbtTp4oCR+UHWw2oT5HUa2H2fI7Nk0EmdhTVMqXFR94d9CQd/OftDwpLetfjYr3cFI50SezKlQBW0qHufHdgnXvKbLZswL8GqVUFsaeSyzdOO4xM0F/Lvpbo1nk1aHWkpFEms6TVIj7ErKFM3Smhlwnfc2MKccfOQCA8n9wMqJJyyaWgdmTB5r9sIV0XVZlCRXpLmFVlnL2NCfM4wc/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: > > > Are you suggesting that the problem is that should_reclaim_retry is > > > iterating nodes which are not allowed by cpusets and that makes the > > > retry loop happening more than unnecessary? > > > > Yes, exactly. > > > > > > > > Is there any reason why you haven't done the same that the page > > > allocator does in this case? > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > index 28f80daf5c04..cbf09c0e3b8a 100644 > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > @@ -4098,6 +4098,11 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned = order, > > > unsigned long min_wmark =3D min_wmark_pages(zone); > > > bool wmark; > > > > > > + if (cpusets_enabled() && > > > + (alloc_flags & ALLOC_CPUSET) && > > > + !__cpuset_zone_allowed(zone, gfp_mask)) > > > + continue; > > > + > > > available =3D reclaimable =3D zone_reclaimable_pages(= zone); > > > available +=3D zone_page_state_snapshot(zone, NR_FREE= _PAGES); > > > > > > > That was my original version, but I found that the problem exists in > > other places. > > Please see the function flow below. > > > > __alloc_pages_slowpath: > > > > get_page_from_freelist > > __cpuset_zone_allowed /* check the node */ > > > > __alloc_pages_direct_reclaim > > shrink_zones > > cpuset_zone_allowed=EF=BC=88=EF=BC=89/* check the node */ > > > > __alloc_pages_direct_compact > > try_to_compact_pages > > /* do not check the cpuset_zone_allowed=EF=BC=88=EF=BC=89*/ > > > > should_reclaim_retry > > /* do not check the cpuset_zone_allowed=EF=BC=88=EF=BC=89*/ > > > > should_compact_retry > > compaction_zonelist_suitable > > /* do not check the cpuset_zone_allowed=EF=BC=88=EF=BC=89*/ > > > > Should we add __cpuset_zone_allowed() checks in the three functions > > listed above, > > or should we set the nodemask in __alloc_pages_slowpath() if it is emp= ty > > and the request comes from user space? > > cpuset integration into the page allocator is rather complex (check > ALLOC_CPUSET) use. Reviewing your change is not an easy task to make > sure all the subtlety is preserved. Therefore I would suggest addressing > the specific issue you have found. > Got it=EF=BC=8Cthanks for your suggestion=EF=BC=8C i will send the next ver= sion soon. > -- > Michal Hocko > SUSE Labs