Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp86959rwb; Wed, 10 Aug 2022 15:23:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LMzSqgV7Xuv1ZjPqMX4hLKGdZhtrsOnNlb+ZVYIgHhZ7LewPSeL6R4/ia6s9uqtWEOhK8 X-Received: by 2002:a05:6a00:3106:b0:52d:53d4:ccc9 with SMTP id bi6-20020a056a00310600b0052d53d4ccc9mr29610203pfb.9.1660170237926; Wed, 10 Aug 2022 15:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660170237; cv=none; d=google.com; s=arc-20160816; b=pw894kwXTFGQtF32hl4nLXVfKPKibKthHWkPU8Cu7oGJbF1AXNGXR0aFa9nPjkfLMS udbU4kVVNyDXmUOwsNXdph19zsneTPFjLz1b11CqUTR5vG4MlmbCKu6cI78hqTP+AOSo yT/dKq7SUiPIVJKi9SD96/Ex7HTRUn3BbuMmR97J2oTy/xCn7VSFuCQGN16fH2VN/tUk uYserySqXXr44xKyHzGkN2+V3OC3F0Tbj2iaobHzEWzmZxB82gLfHRfboHkC9TMZ21nj G/lKPhoV9xIDZs007e7zcnS3dyLg3mHF9z8a8hovphg4HMPkaKpS7/OX66Iv+j8mgxSF WnpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=i0a/3GKlBKDqjZOUqm+Ai/MPjy54p3lvrq9RguS53iA=; b=LT6wv+Y+wj6RBTNkbvss+e/GZjEjVk+znvapu398B4SO8ocCGiobkjEGQ6LubfaWZ5 ipA0OmHT6FHIXQuLIe9ra3UzxrFnfED56gx55tpmjp49T8llW70vD4+77bbkRoDXBQbh jP+9+1r+BUGfol6PSIXU/+in9tU8DN0bFC7TmSOjfD190fmKhltra8nRUJ3Eewu4pOaD 9otRaj0BdK3f8rXoBWQthAXk3O4iXt6NUxtuDkFkx0K8+1xrL1HDW61D/Uam/KOo6wRZ +VDnB5XEzaEQaGQxYcWebM9l60qvimNiYB5nXyYzg+kmijzPnvFhwMsFFDNb+dfF/8qI vpSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=p0rpGImM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a630c46000000b0041c89ab0480si2815513pgm.195.2022.08.10.15.23.19; Wed, 10 Aug 2022 15:23:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=p0rpGImM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232964AbiHJV4v (ORCPT + 99 others); Wed, 10 Aug 2022 17:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbiHJV4o (ORCPT ); Wed, 10 Aug 2022 17:56:44 -0400 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AFB5804BA for ; Wed, 10 Aug 2022 14:56:43 -0700 (PDT) Received: by mail-vs1-xe2a.google.com with SMTP id 66so16564170vse.4 for ; Wed, 10 Aug 2022 14:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=i0a/3GKlBKDqjZOUqm+Ai/MPjy54p3lvrq9RguS53iA=; b=p0rpGImMY6AW4jCBiEqMSb0qwsFuwvHKhj3DlbCGo7b95rUc/MVMhUea3sfVA91KGE 3MYgP/iPPW9Sf1KNPwPVQvNhO+5VoESePEIyM4lu5Oh9wZB17UQQwGdODxlvVp7oY8IM U8DPwu0+3jei0TPQW6eCol6sjxionnEYdRgy7bzzr5nbR3z3y57fgJ9gRKHlL2SDI8Se +8Y3BktA1nOfDxL4c2HczfjpBmE2tmpz/d2lJlk5Y8W8W5h6LKRErCD7uoZ2OGUhCwRu dzIR233tPvE9cEndER1VNHPDVv3VhJW1cxU7K5xSnfxwoD1KZS2DPOgekhqhjWaD/aVW +wwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=i0a/3GKlBKDqjZOUqm+Ai/MPjy54p3lvrq9RguS53iA=; b=Frq2LXzlpJ3JCwHCQct1MHnJUkUqcl8riBiGq0Gny2qDcvwpcN9Bc/ZXRDvHAV1Ti/ 1Fxq28RD6fHRUnx6gYLOm0oVGbMOy8zRgVOTk8/ODvdojnWgZTMrhaUDpYbJcFU/Chzt 6OEvvH211gkkuZmLIJyJva5Dgt3IFTh3YKOVNndavYh2Vm0SWeh3po9G3V2OJMLSN4OY zgrx9OYZ/C3nHxihDdsvPDkrXTW+qdSK3RVuwnjtrZXUlckZitXv/pmZFQ4cG0TSusAz hnZ+c/O5grSR0WbOCN6YOhN/MjP0/5duqKkIEeuRj2rcvxSpC+8vHL7aQz2L3SnaopiU uJBw== X-Gm-Message-State: ACgBeo3Fi3adpmyhkYbOL0ccoYVD6pHq1O4vYHu/MD2LMASluKnXAJll Vz+gMxeeJg4cU87AWdHA/xFhuITY46i8/NqANJZNVA== X-Received: by 2002:a05:6102:665:b0:387:b34:d579 with SMTP id z5-20020a056102066500b003870b34d579mr11978710vsf.50.1660168602569; Wed, 10 Aug 2022 14:56:42 -0700 (PDT) MIME-Version: 1.0 References: <20220805184016.2926168-1-alexlzhu@fb.com> <0b16dbac6444bfcdfbeb4df4280354839bfe1a8f.camel@fb.com> <1F8B9D85-A735-4832-AD58-CA4BD474248D@fb.com> <868F0874-70E8-4416-B39B-DA74C9D76A40@fb.com> In-Reply-To: <868F0874-70E8-4416-B39B-DA74C9D76A40@fb.com> From: Yu Zhao Date: Wed, 10 Aug 2022 15:56:06 -0600 Message-ID: Subject: Re: [PATCH v3] mm: add thp_utilization metrics to /proc/thp_utilization To: "Alex Zhu (Kernel)" Cc: Yang Shi , Rik van Riel , Kernel Team , "linux-mm@kvack.org" , "willy@infradead.org" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" , Ning Zhang , Miaohe Lin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 10, 2022 at 3:39 PM Alex Zhu (Kernel) wrote: > > > > > On Aug 10, 2022, at 10:54 AM, Yu Zhao wrote: > > > > !-------------------------------------------------------------------| > > This Message Is From an External Sender > > > > |-------------------------------------------------------------------! > > > > On Wed, Aug 10, 2022 at 11:15 AM Alex Zhu (Kernel) wr= ote: > >> > >> > >>> On Aug 10, 2022, at 10:07 AM, Yang Shi wrote: > >>> > >>> On Tue, Aug 9, 2022 at 4:36 PM Yu Zhao wrote: > >>>> > >>>> On Tue, Aug 9, 2022 at 11:16 AM Alex Zhu (Kernel) = wrote: > >>>>> > >>>>> > >>>>>> OK, it is hard to tell what it looks like now. But the THPs on the > >>>>>> deferred split list may be on the "low utilization split" list too= ? > >>>>>> IIUC the major difference is to replace zero-filled subpage to spe= cial > >>>>>> zero page, so you implemented another THP split function to handle= it? > >>>>>> > >>>>>> Anyway the code should answer the most questions. > >>>>> > >>>>> They can indeed end up on both lists. This did have to be handled w= hen > >>>>> implementing the shrinker. > >>>>> > >>>>> We free the zero filled subpages, while modifying the existing spli= t_huge_page() > >>>>> function. Will follow up that change in another patch. > >>>> > >>>> FYI. This series does it: > >>>> > >>>> https://lore.kernel.org/r/20210731063938.1391602-1-yuzhao@google.com= / > >>>> > >>>> And this one: > >>>> > >>>> https://lore.kernel.org/r/1635422215-99394-1-git-send-email-ningzhan= g@linux.alibaba.com/ > >>> > >>> Thanks, Yu. I totally forgot about these series. It is time to refres= h > >>> my memory. > >> > >> I looked through these patches yesterday. There are indeed parts that = are very similar, but the approach > >> taken seems overly complicated compared to what I have written. What= =E2=80=99s the status of work on this since last year? > > > > Overly complicated... which patches and how? > > > > At a minimum, you'd need 1 & 3 from the first series and this patch: > > > > https://lore.kernel.org/r/20220608141432.23258-1-linmiaohe@huawei.com/ > > The changes from the previous patches implement freeing of THPs as part o= f memcgroup and reclaim. Zero tail pages are disposed of via > lruvec as part of reclaim. Which series are you talking about? I listed two series and they are very different on the code level. > Our approach is a thp utilization worker thread scanning through physical= memory adding under utilized THPs to a shrinker that calls split_huge_page= (). We free zero tail pages within split_huge_page(). Reclaim will trigger = the shrinker. > > There is some overlap between the implementations, in particular creating= a linked list in the third tail page and methods to check for zero pages. > (I believe the previous patches have a cleaner method for identifying zer= o pages). However, looking through the code I do believe our approach is si= mpler. > > We chose to free within split_huge_page() The 2nd patch from the first series does exactly this. > but it=E2=80=99s worth discussing whether to free zero pages immediately = or to add to lruvec to free eventually. And that patch can be omitted if the third link (a single patch, not a series) is used, which makes the workflow "add to lruvec to free eventually". > I believe the split_huge_page() changes could be valuable by as a patch b= y itself though. Will send that out shortly.