From patchwork Wed Nov 6 22:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11231313 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 7D5041747 for ; Wed, 6 Nov 2019 22:52:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4773F217D7 for ; Wed, 6 Nov 2019 22:52:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="UWC9KHaE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4773F217D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B55F06B0006; Wed, 6 Nov 2019 17:52:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B06516B0007; Wed, 6 Nov 2019 17:52:00 -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 A441B6B0008; Wed, 6 Nov 2019 17:52:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 8EB3D6B0006 for ; Wed, 6 Nov 2019 17:52:00 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 3D8873ABE for ; Wed, 6 Nov 2019 22:52:00 +0000 (UTC) X-FDA: 76127352000.02.fruit38_68c0f011ddd01 X-Spam-Summary: 20,1.5,0,5d198b15a7cfd928,d41d8cd98f00b204,prvs=6213eeccd2=guro@fb.com,::akpm@linux-foundation.org:mhocko@kernel.org:hannes@cmpxchg.org:linux-kernel@vger.kernel.org:kernel-team@fb.com:guro@fb.com:stable@vger.kernel.org:tj@kernel.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1711:1730:1747:1777:1792:2194:2199:2328:2393:2559:2562:2693:2741:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:3874:4321:5007:6261:6653:7903:10004:10400:10450:10455:11026:11658:11914:12043:12114:12297:12438:12555:12679:12895:13069:13161:13229:13255:13311:13357:14096:14097:14181:14394:14721:19904:19999:21080:21451:21627:30054:30064:30070,0,RBL:error,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:28,LUA_SUMMARY:none X-HE-Tag: fruit38_68c0f011ddd01 X-Filterd-Recvd-Size: 4163 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Nov 2019 22:51:59 +0000 (UTC) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.42/8.16.0.42) with SMTP id xA6MppPW027663 for ; Wed, 6 Nov 2019 14:51:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=b0a5BpouPO7gAbWCAkVMisyIA5YcsFbBQ4BU5Ai03bM=; b=UWC9KHaEbkVNUgaOoSvyamwSww4roUVDbdPbnYQhZxJ7ke8Sipknv7Bzpb70NkOa250y vx2vnKWmC31tAjS4mXDvVo7DrSWpJoKmDiTsG016ZvPhCG+/JJuY8HUc2d9AbGkrw6Uv TPh1fqXjxmk9UJWlYzacTYonZu2bTOj+Wis= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0001303.ppops.net with ESMTP id 2w41vc9sq9-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 06 Nov 2019 14:51:59 -0800 Received: from 2401:db00:30:6012:face:0:17:0 (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Wed, 6 Nov 2019 14:51:45 -0800 Received: by devvm2643.prn2.facebook.com (Postfix, from userid 111017) id 60B3D19E16A83; Wed, 6 Nov 2019 14:51:44 -0800 (PST) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm2643.prn2.facebook.com To: , Andrew Morton CC: Michal Hocko , Johannes Weiner , , , Roman Gushchin , , Tejun Heo Smtp-Origin-Cluster: prn2c23 Subject: [PATCH 2/2] mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() Date: Wed, 6 Nov 2019 14:51:31 -0800 Message-ID: <20191106225131.3543616-2-guro@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191106225131.3543616-1-guro@fb.com> References: <20191106225131.3543616-1-guro@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-06_08:2019-11-06,2019-11-06 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 bulkscore=0 mlxlogscore=748 impostorscore=0 adultscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911060220 X-FB-Internal: deliver 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: An exiting task might belong to an offline cgroup. In this case an attempt to grab a cgroup reference from the task can end up with an infinite loop in hugetlb_cgroup_charge_cgroup(), because neither the cgroup will become online, neither the task will be migrated to a live cgroup. Fix this by switching over to css_tryget(). As css_tryget_online() can't guarantee that the cgroup won't go offline, in most cases the check doesn't make sense. In this particular case users of hugetlb_cgroup_charge_cgroup() are not affected by this change. A similar problem is described by commit 18fa84a2db0e ("cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css()"). Signed-off-by: Roman Gushchin Cc: stable@vger.kernel.org Cc: Tejun Heo Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt Acked-by: Tejun Heo --- mm/hugetlb_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index f1930fa0b445..2ac38bdc18a1 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -196,7 +196,7 @@ int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, again: rcu_read_lock(); h_cg = hugetlb_cgroup_from_task(current); - if (!css_tryget_online(&h_cg->css)) { + if (!css_tryget(&h_cg->css)) { rcu_read_unlock(); goto again; }