Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp161239ybx; Wed, 6 Nov 2019 14:56:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxAX9SXnUQeNH5bOUnllzBoXBv7z6eiMwQ9zT7GGWe3ohMiM+oOrfz77yRIJHjoR4/JvTih X-Received: by 2002:a17:906:14d4:: with SMTP id y20mr84236ejc.21.1573080983035; Wed, 06 Nov 2019 14:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573080983; cv=none; d=google.com; s=arc-20160816; b=YYsqtIXg66p8e1zYD+ToG9h+OxCQNP37QpJgP+Kab5IcHi1612hpNTCi2mQu6Xbc+X hzdKjDjf+eak7NUpsmHyTP3M811T2IUuh692rZqbPpOySmaO0Ol5eHZ8kkvjFT6XA0fK 57VN0hjyNZm6Y1Jgb61Vn/t0lYDu5M1nO2wslSHZLAk7KDAbIH7JCS6uLR/ZLDF5pc8f hu7jpPwXgh4BAtUz7E61RF7L/+wC5LUQ/EpH23YUw8FNgKec7Uc3PXFsCXck0QsC5fj/ yYebGa1DKMI5hIEMs/40CQWLZ8AIRT2Aupe7njfXDNPwrDnZvsUAMv9qr1Xsz3a6iM4k 3pfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix:dkim-signature; bh=b0a5BpouPO7gAbWCAkVMisyIA5YcsFbBQ4BU5Ai03bM=; b=EPscSLoY9bV5ZY8n9NsIl1kNoPblQu1zaBmh2UQWqyCr+6yH1EhWdsQDY1gLDQ+xaZ UMVl886VJsUantBTcpJEAom/Cu8xf08nNSl8+b5VViwKPlJookwM4Ee+15nWyPJovAmw kAdNIYM+12qQS3H4CYdosphWxBlkHSFV1ebNLbqY1gcJgLlTAQIk53IaNwkVjQ1MObOQ hrvaZONnzfWvvPQF+fmqL+Oo2ll9pfl9n19AepUi+W+YIO/J0AUYXkkur1sU8RnLKe2V 4xWpuCcO9ccANf8b7OjjD2H+P5bMHFLqk/NXadm6tv7XGtyHzoQCht2SnbUMwLumaOKh 8TpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=UWC9KHaE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si26067ede.12.2019.11.06.14.55.59; Wed, 06 Nov 2019 14:56:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=UWC9KHaE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732830AbfKFWwt (ORCPT + 99 others); Wed, 6 Nov 2019 17:52:49 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:7648 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbfKFWvr (ORCPT ); Wed, 6 Nov 2019 17:51:47 -0500 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xA6MmG0F020832 for ; Wed, 6 Nov 2019 14:51:47 -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 mx0a-00082601.pphosted.com with ESMTP id 2w41vxssww-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 06 Nov 2019 14:51:47 -0800 Received: from 2401:db00:30:6012:face:0:17:0 (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::126) 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 Content-Type: text/plain 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 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxscore=0 suspectscore=0 bulkscore=0 phishscore=0 adultscore=0 mlxlogscore=752 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911060219 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.17.1