From patchwork Tue Feb 11 05:24:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11374831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37C26138D for ; Tue, 11 Feb 2020 05:24:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 047C02082F for ; Tue, 11 Feb 2020 05:24:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 047C02082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A7F16B0282; Tue, 11 Feb 2020 00:24:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2581F6B0283; Tue, 11 Feb 2020 00:24:29 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 195786B0284; Tue, 11 Feb 2020 00:24:29 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id 027DA6B0282 for ; Tue, 11 Feb 2020 00:24:28 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A8CB72494 for ; Tue, 11 Feb 2020 05:24:28 +0000 (UTC) X-FDA: 76476705816.09.range30_61279420f2836 X-Spam-Summary: 2,0,0,b9eeca5b937bc283,d41d8cd98f00b204,yang.shi@linux.alibaba.com,:akpm@linux-foundation.org:yang.shi@linux.alibaba.com::linux-kernel@vger.kernel.org,RULES_HIT:41:355:379:541:960:965:966:973:988:989:1260:1261:1345:1437:1534:1539:1711:1714:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3351:3867:3871:4321:4385:4390:4395:5007:6261:8660:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12895:13069:13141:13148:13230:13311:13357:13972:14181:14384:14394:14721:21060:21080:21212:21324:21627:21990:30054,0,RBL:115.124.30.42:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: range30_61279420f2836 X-Filterd-Recvd-Size: 1711 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 05:24:27 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0TpeDbVp_1581398649; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TpeDbVp_1581398649) by smtp.aliyun-inc.com(127.0.0.1); Tue, 11 Feb 2020 13:24:18 +0800 From: Yang Shi To: akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails Date: Tue, 11 Feb 2020 13:24:08 +0800 Message-Id: <1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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: When kstrndup fails (returns NULL) there is no memory is allocated by kmalloc, so no need to call kfree(). Signed-off-by: Yang Shi Acked-by: David Rientjes Reviewed-by: David Hildenbrand Signed-off-by: Yang Shi Reviewed-by: Andrew Morton Reviewed-by: David Hildenbrand Acked-by: David Rientjes Signed-off-by: Andrew Morton --- mm/vmpressure.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 4bac22f..0590f00 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -371,10 +371,8 @@ int vmpressure_register_event(struct mem_cgroup *memcg, int ret = 0; spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL); - if (!spec) { - ret = -ENOMEM; - goto out; - } + if (!spec) + return -ENOMEM; /* Find required level */ token = strsep(&spec, ","); From patchwork Tue Feb 11 05:24:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11374833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA760138D for ; Tue, 11 Feb 2020 05:24:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B91A12082F for ; Tue, 11 Feb 2020 05:24:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B91A12082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 038166B0283; Tue, 11 Feb 2020 00:24:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F296A6B0285; Tue, 11 Feb 2020 00:24:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3E9F6B0286; Tue, 11 Feb 2020 00:24:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id C9AC16B0283 for ; Tue, 11 Feb 2020 00:24:37 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 677C4180AD804 for ; Tue, 11 Feb 2020 05:24:37 +0000 (UTC) X-FDA: 76476706194.05.can86_6244569070b46 X-Spam-Summary: 2,0,0,28c2403ab0b9944e,d41d8cd98f00b204,yang.shi@linux.alibaba.com,:akpm@linux-foundation.org:yang.shi@linux.alibaba.com::linux-kernel@vger.kernel.org,RULES_HIT:41:355:379:541:960:973:988:989:1260:1261:1345:1359:1437:1534:1539:1568:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3866:3867:3871:5007:6261:10004:11026:11658:11914:12296:12297:12555:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21627:21990:30054:30070,0,RBL:115.124.30.43:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: can86_6244569070b46 X-Filterd-Recvd-Size: 1814 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 05:24:34 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04396;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0TpeTAeD_1581398658; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TpeTAeD_1581398658) by smtp.aliyun-inc.com(127.0.0.1); Tue, 11 Feb 2020 13:24:29 +0800 From: Yang Shi To: akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm: vmpressure: use mem_cgroup_is_root API Date: Tue, 11 Feb 2020 13:24:09 +0800 Message-Id: <1581398649-125989-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com> References: <1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com> 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: Use mem_cgroup_is_root() API to check if memcg is root memcg instead of open coding. Signed-off-by: Yang Shi Acked-by: David Rientjes Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- mm/vmpressure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 0590f00..d69019f 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -280,7 +280,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, enum vmpressure_levels level; /* For now, no users for root-level efficiency */ - if (!memcg || memcg == root_mem_cgroup) + if (!memcg || mem_cgroup_is_root(memcg)) return; spin_lock(&vmpr->sr_lock);