Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp528086lqh; Tue, 7 May 2024 06:45:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXL5kI5OkbofMK4sgOj0yy4c6Cmv720O95qefE9FLmWMlyaim8ffhJncWLCjeYbnMN12POOIHcB56n9UaOceqoumlJZoaNwISEtESQQZQ== X-Google-Smtp-Source: AGHT+IE3x9ynurB62PMyo90zbO5LuI4v0TFlX9+PrIjSBUFwlkRAzmeL8y3fPSY9619U6+VEu3s1 X-Received: by 2002:a05:6a20:7f9b:b0:1a7:99c5:802 with SMTP id d27-20020a056a207f9b00b001a799c50802mr18423749pzj.37.1715089505068; Tue, 07 May 2024 06:45:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715089505; cv=pass; d=google.com; s=arc-20160816; b=zap2QXrivVY0yf7YlSs3KBgqAuLmYtuI7Ab8Izj8XiTPiN0xvbHO7cVCfyMQLy4H9e 1J7lzc7NlgzvtndhV1A7+qZPRoRzyYM7YiWdmYlYKjlz5p6NKF5eb7QidK9FgJuw4SXP o6wB+2Bt+XCw9wKXitJ0ANCc/zp5aV1fOe7czpd6bMhvsZFu5uSrB58R5uBoEL0LX//l TUYjZkh2SRLWQuoSs6b24urta2ueLi9ocyHD+jfIKIS34WxzO3BK9qZ22cFxKABNP1ua lEGSIhz9cqmNQ/GRkfB0Ty8pLBWeXyGJQEk+rlsskF96zzWLDGoZtqMthu+OCWkubsaP HaSw== 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=wHomnQPsq1BIB95P/lqOebqIn+KzAQbfhmlEwjWgSLE=; fh=uEpp58aX4v2HXbDJbq05LBbyUPDiBYVghITlypUBHZY=; b=ccNU3aqUyDeYbQNwoQ6ZXrKeHkIu/yug+JS6S5je7QTLqsUQzEQn2kj7g0dJZ/SB0G rf4m7IKvF4aAe99itm3Q6GZVksZ1NKGjtUeZ857hpV4HR8SG9TdtxpSNdJuTkT1b4Mml HNPEJWhda+mDtUF5Yg79kXbfE59Vo1IjPSNsuci67bl89Pdd6pzi/Ze0XSwdRWrj+UxB z1mfD3SBOkBWM51Q9iBNi8Aps7yK2pYu0L/Ypn20w4QtrLYHzwwtxweNpkkRZ5JlgAWH 0BikxIKEy6GS82Fr2ywYjnv/KX4dGmxnqhhBYeTqc3TKJ/LcBMkviJZ6NW22l14pmuBH /7Ow==; 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-171443-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171443-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. [139.178.88.99]) by mx.google.com with ESMTPS id 185-20020a6301c2000000b005d8e3c86163si10506002pgb.142.2024.05.07.06.45.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171443-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-171443-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171443-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 4CC72288921 for ; Tue, 7 May 2024 13:39:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B188F16C6AA; Tue, 7 May 2024 13:31:45 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 187F216C45B; Tue, 7 May 2024 13:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715088705; cv=none; b=XEUQlKqYqefET9OgKgQGIhN/huhtMDK5LSKS/XfwVh/BOX6B8kTA3XGqLBuZF6i52sg+FC6hFwygmu4pKBdgUJlAtBEYA0x+08hbbRQq1BkomoqKvX3r205Wwauje+eIdjxAVQk9T/MDqScQIk+2g7FuUvP675vgIu3TP0tOtQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715088705; c=relaxed/simple; bh=Z3Oh7sCEytYAY+1dl6YfvZQmJ7dlWmL4kQ0K0NhJyGs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Vp7p4L9eF0ZRWGLWYt+V3VDMp0bG6ZmZvxCnIqcrIcabIEBWKct2NJI9TDXa0/iA9R0i+OGYjZyw4BM7c/K4kX3lDspM2i7QMbU6zvJwAr1W0a9KP8gedfellJbwrUbg5eK00cycgviqe8FU8Q0Re2FWEJiw6V1em85o3pYdCg0= 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.187 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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VYfH32hTsztT4H; Tue, 7 May 2024 21:28:15 +0800 (CST) Received: from dggpeml500023.china.huawei.com (unknown [7.185.36.114]) by mail.maildlp.com (Postfix) with ESMTPS id 7EE801800C9; Tue, 7 May 2024 21:31:40 +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.35; Tue, 7 May 2024 21:31:40 +0800 Message-ID: <10484734-13e6-4c56-d7dc-6c4cf74bd8de@huawei.com> Date: Tue, 7 May 2024 21:31:39 +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] mm: memcg: make alloc_mem_cgroup_per_node_info() return bool Content-Language: en-US To: Michal Hocko CC: , , , , , , , References: <20240507110832.1128370-1-xiujianfeng@huawei.com> From: xiujianfeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500023.china.huawei.com (7.185.36.114) On 2024/5/7 21:10, Michal Hocko wrote: > On Tue 07-05-24 11:08:32, Xiu Jianfeng wrote: >> Currently alloc_mem_cgroup_per_node_info() returns 1 if failed, >> make it return bool, false for failure and true for success. > > This describes what the patch does rather than why it is doing that. > The former is clear from the diff while the motivation for this change > is unclear. I would propose something like: > > alloc_mem_cgroup_per_node_info() returns int that doesn't map to any > errno error code. The only existing caller doesn't really need an error > code so change the the function to return bool (true on success) because > this is slightly less confusing and more consistent with the other code. Thanks, it looks much better now. > >> Signed-off-by: Xiu Jianfeng > > With changelog clarified feel free to add > Acked-by: Michal Hocko > >> --- >> mm/memcontrol.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index d11536ef59ef..69d70feb8e68 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -5653,13 +5653,13 @@ struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino) >> } >> #endif >> >> -static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) >> +static bool alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) >> { >> struct mem_cgroup_per_node *pn; >> >> pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, node); >> if (!pn) >> - return 1; >> + return false; >> >> pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL, >> node); >> @@ -5675,11 +5675,11 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) >> pn->memcg = memcg; >> >> memcg->nodeinfo[node] = pn; >> - return 0; >> + return true; >> fail: >> kfree(pn->lruvec_stats); >> kfree(pn); >> - return 1; >> + return false; >> } >> >> static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) >> @@ -5751,7 +5751,7 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent) >> } >> >> for_each_node(node) >> - if (alloc_mem_cgroup_per_node_info(memcg, node)) >> + if (!alloc_mem_cgroup_per_node_info(memcg, node)) >> goto fail; >> >> if (memcg_wb_domain_init(memcg, GFP_KERNEL)) >> -- >> 2.34.1 >> >