Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp81087lqp; Mon, 10 Jun 2024 19:29:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtZGcKLLjY5M9rk3oxPfaqfu4G9fj+ru87nSGRdsESLwQAQVH1Hy/elVqBNjcuP1dwdzPNSOCI4eFXnTKRt4M9XwDrZwmmJ7rc6KNH7Q== X-Google-Smtp-Source: AGHT+IFls1HK8KM+p4nNzMloJpR2dSXMy9CbcMnMQPdHMWJncz4sLaKBKEwtY/ak5aBZL2bopevt X-Received: by 2002:a17:902:ea0b:b0:1f6:92f1:b01c with SMTP id d9443c01a7336-1f6d03b9604mr143941175ad.69.1718072949431; Mon, 10 Jun 2024 19:29:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718072949; cv=pass; d=google.com; s=arc-20160816; b=uyjBZEmEMtc89Y7Vy2h2ooWNo5CY8Lg+xBQWv1chFBtKi5ANM/Kd7lXst3lAnCNOpb ndryxW2SjTnzcQMGSzTWoqEpjnZXj6B7ReGNgqtnVUzxOCma5B0G7ObS8QU0bi7yn4P+ c0rQfwFuLOU02QYoSbqWBGuEPzWvV15U5kvARzb1XxLbcsc23DFV25CqevAXeeM7NARC BimSyESF8umg2WTii7NTzw1dwwIvOMrMcyKv9cMUByKHgZxz0g6Ij+1Bi3EsaxeUZYCt 8LroL9XRaVc9IRg94xBsT1NGCngkEGRADTtlRsS6AifP5EauMp0QcPfyrPwUQZ2WpXMZ 4tZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=+NrUFfOeYzZzCWPuXtKijgWlIY8Q9sBnxpFFo1JIe7E=; fh=dQghsOwpzcagBopj04Ffe+IpkpThgleSUhnbO9z9cqI=; b=zDtEDtAJqIadrph8uRdBIUKnOSD0kgi76tShaiso9BgJxo0sFdpxrn8t8GZc9wLsX6 CsoZ8hiObaZN+46e9QfzEiSg7dm5S6uOA3dXvoCdA1cwFPSvrHf9CTGk0RX2hwuVmlMh 6UGlj3sbVrwqE/X8l9V+6aXutQEbWZ+F28iqgChqtGA76bnTpWoxcox5ToUn7IdW5GPM 2iGea9bKXOgSvVQORsi4nvySnjk/nuxyI86fr1kjdtm7eJrS57B5bkXZVJwaMPGWnZ5G RPUSR9BNwue73V6oswACK5Kqb9BaAnFp+4jGAerWK43IOpe0lG3g2xt5cdr40ZBLKq2w 89YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-209182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f714cf9163si27484915ad.426.2024.06.10.19.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 19:29:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-209182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 15B9F282D94 for ; Tue, 11 Jun 2024 02:29:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2E1915ADA6; Tue, 11 Jun 2024 02:29:02 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0D58C04 for ; Tue, 11 Jun 2024 02:28:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072942; cv=none; b=WD/K8ssbxanIROJg7vIGrSLIU7ILn/DfdpUUh+fshTLH/tgC/2+WqZMd9GJAfvsCrFKmkpHvzcmd05QCATqCOVXH2VmxWtMvPaIK8ahc341VPHCdfZcL6+Om8u9q+K7EgYRxClCd1Hm9vnIfGTIsCZA44UlWOQGFPICaIlBbjOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072942; c=relaxed/simple; bh=wRRaHIRbGSEyP4emDGB1kR9GyFY+tZkrm2SssqU5Msc=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=NngeBjQbcDpU0QHMH8lMmAf1yZhRQPOgB8+v1SHVKCJKOJzwK/OUzj3evB2Uozc92Jshv7GoFLblpGff7FrvTGTILnKLp59L+al8NYVxzLTJwRvuTuJYh8V4whhyiGPoeVG+NqQaUek53m9rN42n3Kwnk1c6Hqr2v+jnVQeUbWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VysvL4xBnz1SBhH; Tue, 11 Jun 2024 10:24:46 +0800 (CST) Received: from dggpeml500023.china.huawei.com (unknown [7.185.36.114]) by mail.maildlp.com (Postfix) with ESMTPS id 95C1514041A; Tue, 11 Jun 2024 10:28:50 +0800 (CST) Received: from [10.67.110.112] (10.67.110.112) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 11 Jun 2024 10:28:50 +0800 Message-ID: <01e9ccca-c266-face-6854-40b2d6020a16@huawei.com> Date: Tue, 11 Jun 2024 10:28:49 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2 -next 1/3] mm/hugetlb_cgroup: identify the legacy using cgroup_subsys_on_dfl() Content-Language: en-US To: Oscar Salvador CC: , , , References: <20240605070133.1941677-1-xiujianfeng@huawei.com> <20240605070133.1941677-2-xiujianfeng@huawei.com> From: xiujianfeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500023.china.huawei.com (7.185.36.114) On 2024/6/10 13:03, Oscar Salvador wrote: > On Wed, Jun 05, 2024 at 07:01:31AM +0000, Xiu Jianfeng wrote: >> Currently the numa_stat file encodes 1 into private using the micro >> MEMFILE_PRIVATE() to identify the legacy. Actually, we can use >> cgroup_subsys_on_dfl() instead. This is helpful to handle .private >> in the static array of the comming patch. >> >> Signed-off-by: Xiu Jianfeng > > Reviewed-by: Oscar Salvador > > Nit below: > >> --- >> mm/hugetlb_cgroup.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c >> index e20339a346b9..45f94a869776 100644 >> --- a/mm/hugetlb_cgroup.c >> +++ b/mm/hugetlb_cgroup.c >> @@ -460,7 +460,7 @@ static int hugetlb_cgroup_read_numa_stat(struct seq_file *seq, void *dummy) >> int nid; >> struct cftype *cft = seq_cft(seq); >> int idx = MEMFILE_IDX(cft->private); >> - bool legacy = MEMFILE_ATTR(cft->private); >> + bool legacy = !cgroup_subsys_on_dfl(hugetlb_cgrp_subsys); >> struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(seq_css(seq)); >> struct cgroup_subsys_state *css; >> unsigned long usage; >> @@ -839,7 +839,7 @@ static void __init __hugetlb_cgroup_file_legacy_init(int idx) >> /* Add the numa stat file */ >> cft = &h->cgroup_files_legacy[8]; >> snprintf(cft->name, MAX_CFTYPE_NAME, "%s.numa_stat", buf); >> - cft->private = MEMFILE_PRIVATE(idx, 1); >> + cft->private = MEMFILE_PRIVATE(idx, 0); > > Do we still have to set it to '0'? > Is it not by default? > Hi Oscar, Thanks for your review. Not all files care about the value of the second argument of MEMFILE_PRIVATE(), but all files care about the value of the first argument 'idx', so the .private must be explicitly set, and passing 0 as the second argument can be treated as 'not caring what its value is'. Setting it to 0 or 1 does not affect the functionality, but it makes the semantics more clear, IMO. However, you've reminded me that the reassignment of .private in the second patch is problematic, and I will make a comment on that patch.