Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp360772ybx; Wed, 6 Nov 2019 18:33:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzowcJUFM4MzsFYwceavadY0aW2MDLFmf8qDYUQS5OIB3ePCZ8YJjBBxGrZdorSRa1IrQw+ X-Received: by 2002:a50:8871:: with SMTP id c46mr1124761edc.24.1573094006260; Wed, 06 Nov 2019 18:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573094006; cv=none; d=google.com; s=arc-20160816; b=Nb7Na6CR2t90duz4Xhq6nwkwUDorQTomdS5/cm3u8f0uqfqOeIxHR/0nZqS0BhRNld kg6cspk4PBveALfFuVehQ/R4IvmN5mqkhy5kzgpFAFFwNxiavf/g/f2dCpzAB1MyvxoG iOIBOeoxsxddKLxl99nsbm3Q3nzuEQzjaLLvJ1NQUqo6OQyQ8BDBR5FV35KfHbY+fkCz KcA/F0uBmDUiN0Q/o6fgpEQY7OydTvAwSkc0M+RdW4nX/PnWVQoywC30Dwe+q8GrZAI/ pMo5dHzjaMeHH0DlmH4KUhlRX2gXML+pMzdRfkWFs8vRxMniVnNaZBs+P39gm44vFiUX 53vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AHeH+k3q1YGRdVcK71lwkaCtcvgP7dVsV5GnTtoj2xs=; b=WnvW1qkueC9z13qHfpH1ICt2eF8X7459RXXDnEzkKdUScT4ztzc+ARJH3g3H2K6AWW /dGiWZasPHl44TGOMuTWvOWVgYM4Q3LvEcP9LfMMSsfZcp0DsFDGTdWokisTcGCMNMnT g0YF6TnGd1Y27KOnmq0Nf9gP9x63CgpriRJ+PppKxKWClgHC6eG1R/aTcm07onn7l136 3zvdoasA67FvtOTPxcJwCDuwbEiB9e2RzxZHphRbZb2VifALKw38o3cqW1uWmBlyFquI JikqTaM0VMOxDWIezJ8HFhRnywCANske5h8tweIdFk+ZwkhSDrHvdVIZgVFxt3Xb+Sy5 0WTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DEq2d9wP; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si542052ejw.13.2019.11.06.18.33.01; Wed, 06 Nov 2019 18:33:26 -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=@google.com header.s=20161025 header.b=DEq2d9wP; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732941AbfKGCcI (ORCPT + 99 others); Wed, 6 Nov 2019 21:32:08 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:34505 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbfKGCcI (ORCPT ); Wed, 6 Nov 2019 21:32:08 -0500 Received: by mail-oi1-f193.google.com with SMTP id l202so649718oig.1 for ; Wed, 06 Nov 2019 18:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AHeH+k3q1YGRdVcK71lwkaCtcvgP7dVsV5GnTtoj2xs=; b=DEq2d9wPFiLHlbBQh4T+yaRBQsYILaoQXq1yI4S1YiUQbtgMwYBgOoYV88hwOdZMU5 GHnkt3p84ev9URkfVlSTUApIfb/xp6J1w6wbf46IFkrE2Uxi1de+IGf2+F/G3Skls/0Z h8H060f0oB8KOVdroNFU9e3cmJh4yB18mqmI6UcP7NAgoNNy+AYMzlK/Ti9N0lVdmrW4 +J+jisaNy7CTzmhSNNM7yNU5UDAMsZQEsTKcmn1S3cqaefQc5PxCFavlItazoFxA8BEq QUAXc5NnNs0sbaxmyPfFC326BfQypv4XYu8MYRzOmSzdgHUETuJdpFv9Me35Ho33B8sT +RVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AHeH+k3q1YGRdVcK71lwkaCtcvgP7dVsV5GnTtoj2xs=; b=BlMY+cMxV74eFH3TLVQQvAlToEWi5SFtdx+Refd3IqQrtpPUNseMSwWlmCpqo17T9X 7zW4FvpgJabS+vNFo7bCoTLV7llN9/4fhBDoFY3DfLqLHkSlvOZTMhS/sh+v53lTacq3 orRXFaQ6QEAKhhQV5hk55OcZOw+PrzipBQP+2xCt8cLKVNZCfpESs82mZKCNlnVTsA3H DvllqY/voT6Maq1qI6LBIldKqZCMJDiKPpiEBxc61xs0Kjx54mV3NJ3xx+2dB9U1xsKC tjDAPPthjCjezyTsCOOTLc8SGglf6KLMGIoEsS/NaiusPLboQ5UUE/oAM0tgNHlkywqO QU0g== X-Gm-Message-State: APjAAAUUs9ZuFZspBvcEUcSUOgdLRaVuvRExTa2xFPOwWPjZ6cQe6jeI Qn3EIA/mEmeWeFya4wal2LmC1RCC+ysbcrbZH7/3RA== X-Received: by 2002:a05:6808:9ae:: with SMTP id e14mr1055079oig.79.1573093927619; Wed, 06 Nov 2019 18:32:07 -0800 (PST) MIME-Version: 1.0 References: <20191106225131.3543616-1-guro@fb.com> <20191106225131.3543616-2-guro@fb.com> In-Reply-To: <20191106225131.3543616-2-guro@fb.com> From: Shakeel Butt Date: Wed, 6 Nov 2019 18:31:56 -0800 Message-ID: Subject: Re: [PATCH 2/2] mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() To: Roman Gushchin Cc: Linux MM , Andrew Morton , Michal Hocko , Johannes Weiner , LKML , Kernel Team , stable@vger.kernel.org, Tejun Heo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 6, 2019 at 2:53 PM Roman Gushchin wrote: > > 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 Reviewed-by: Shakeel Butt > 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 >