Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp20666rwb; Wed, 10 Aug 2022 18:22:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5LR91PMG3cT1SHbFJq22j00OkNza0W2n6lNtBt5ZQoGuKuC0trfN1UtzI0cXp8bOOc0EmG X-Received: by 2002:a17:906:93fa:b0:731:a80:2444 with SMTP id yl26-20020a17090693fa00b007310a802444mr18440563ejb.121.1660180968354; Wed, 10 Aug 2022 18:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660180968; cv=none; d=google.com; s=arc-20160816; b=nRS+Nk6B5FFA34wL6KArJg+CkBZMlw2csGglEyNyz3ltJuh2PoC2XU3YyVIchbWz60 v0DRMdWBJDZ0GXoQ+Y67mliln9KhYHV9g+B2nQDA9XhIOLviRaLWU/fDDuoLgIsg6Elu TeiM43fbThr40Of8/JuU5wUoZniMaS99xk1B73qEmP04+OOZDQVyynX/XC2InZhZW3UQ 9drUfHzMRPrCStJ56xXMuD0qqS6UxzqR2UPcZFWmptqvBsS6mgAHes52BqemRJeL6TP+ X82TIowSOeLKvnf0zV9h0WnOTzlVueQe23/DvU6mKMJj8a2h9dtdpQ1ZtkMqIKh2PxrG v6FQ== 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=ra3ydByKKM5WStToQCHjdG6o8mmaoU8fttyOCtEBbrY=; b=n8QjnlbVgnkaMF0/xlTxxIMKyIlCxr3cC2E9nXvoDj+OCVIsCxcSWaOJWSUOlHTtHg pDbyBl6B+WQiX7Je38PQA+uu2cmq7IaCSi1vVxrdbvUiVw51tFM4iI4C5nRC3pumaORt cyZgQUCtYM0kz0TcEWHKwGcFTfi357eql/CryWdL20kZSbejcGoAm0DzzyUbzlWqf5se BEWrYZb+74+Zl10P3HccE82PpIoJbYiMqVeztV8eBXBkbqUlzU0Wrw6Og1qFa0gNWijQ kUUKViClXwz0BQEcPC6GIQ0D2fd+ph1rernn5jKBDERboR8zJdb0BQSy8QwvgVYcC1nZ hwNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=J5TW9q0D; 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 z6-20020a056402274600b0043e1c8b6187si17050546edd.1.2022.08.10.18.22.22; Wed, 10 Aug 2022 18:22:48 -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=J5TW9q0D; 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 S233366AbiHKBPr (ORCPT + 99 others); Wed, 10 Aug 2022 21:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiHKBPp (ORCPT ); Wed, 10 Aug 2022 21:15:45 -0400 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39C45005E for ; Wed, 10 Aug 2022 18:15:42 -0700 (PDT) Received: by mail-vs1-xe34.google.com with SMTP id c3so16914687vsc.6 for ; Wed, 10 Aug 2022 18:15:42 -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=ra3ydByKKM5WStToQCHjdG6o8mmaoU8fttyOCtEBbrY=; b=J5TW9q0DopUBP+vAlcG1ZUarFhkG5jZK+dtQw7muCjY0kiL3Bsa5ko9Ua3xMtiY0SS m60Vy/KuCLBMDsdcDgxlEgfexk8SjERDglyifjQsPg6Y/EwzxFuOZbAdhyifMIMI6EKO 9SlUuyWf2gJFiLXjay61AtRymbiwVKy6iKT2J1GbRc2BzupnqWYOhU8/dqv46DchAFg6 8ZEjBXzPgWqiscSfGxf9OtUuVaxY76JbdepF+GWdcu90AD+BTNR3lmq7wHgCj6PVeRpX 7HgJ1xWhREVNsYktLm4/8j4Rh7SiYNjJobEHnRajsabVe01247vwiim20AxwLnadYKtY atHQ== 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=ra3ydByKKM5WStToQCHjdG6o8mmaoU8fttyOCtEBbrY=; b=WYY5JmfiM7JgTwjtZGVe57vG1QPt+7Xtmy/J2uK7mpvGxIeW/vLvc22iTU9nt2zKn0 elB8N1U9NYFm8TcyN6XWwJQkBDwiM1S9TUV1gQNYxVvm2UQQBHascRGSzADzANjjRzC3 g29j+ujGGWPHyv4gPq7K3e2N+xAJMc6QAeINCAGat6QB4U6R7E5MsH70dvC0iMnMg22+ PUVy/4ncq1yQ/EX0YE/pP2ndtNS8nj0fM26UWnDXzhEZevaaG361ndbsGtVqY6Pg67a6 1CaOx5P1J0jI+pd4ohf3V+P+GGh5N3ERq0IW/zFpkE7FWFDh9/As2yw3m30lN3kMlpVo BaqQ== X-Gm-Message-State: ACgBeo3C/9R7/MOiBLytPwZQV8HAyiloi+tAOMdG73NqxlOxJuOrAoiC kD7qMcbtlQEVgI9YlUivKebwi1ZXKL6cAsQhBxINyg== X-Received: by 2002:a05:6102:5094:b0:388:6903:5f09 with SMTP id bl20-20020a056102509400b0038869035f09mr12494985vsb.46.1660180541484; Wed, 10 Aug 2022 18:15:41 -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: From: Yu Zhao Date: Wed, 10 Aug 2022 19:15:05 -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 6:00 PM Alex Zhu (Kernel) wrote: > > > > Which series are you talking about? I listed two series and they are > > very different on the code level. > > > > I was referring to the second patch: https://lore.kernel.org/all/16354222= 15-99394-1-git-send-email-ningzhang@linux.alibaba.com/. You mean the second patch*set* or series, the link doesn't point to a single patch :) "the second patch" could mean the second patch in that series. > This patchset adds the THP shrinking as part of shrink_lruvec in mm/vmsca= n.c. We create a new shrinker that shrinks THPs based off the results > of the scanning implemented in this thp_utilization patch. We also do not= have any of the additional knobs for controlling THP reclaim that the patc= hset above has. That seems unnecessary in the initial patch as shrinking TH= Ps that are almost entirely zero pages should only improve performance. > > I believe the resulting implementation we have is simpler and easier to u= nderstand than the above patchset. By identifying and freeing underutilized= THPs we hope to eventually deprecate madvise entirely and have THP always = enabled. > > > The 2nd patch from the first series does exactly this. > > > >> but it=E2=80=99s worth discussing whether to free zero pages immediate= ly 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 patc= h by itself though. Will send that out shortly. > > Referring to this patch: https://lore.kernel.org/r/20210731063938.1391602= -1-yuzhao@google.com/. > > We do indeed do something similar to patches 1 and 3. We may be able to m= ake use of this instead, I=E2=80=99ll take a closer look. Please do. Based on what you said ("chose to free within split_huge_page()"), I very much suspect you do something similar to patch 2 as well. IIRC, that location is the best location to free subpages that only contain zeros because it covers multiple scenarios.