Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2976729pxb; Fri, 5 Nov 2021 07:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKDprygyHD64dzLDfTnCyUm3llg1glAM3/fFahCKWa/caKbSlyi4JNcG2n15lSgrzSkNmb X-Received: by 2002:a05:6e02:12c3:: with SMTP id i3mr32068641ilm.316.1636123681966; Fri, 05 Nov 2021 07:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636123681; cv=none; d=google.com; s=arc-20160816; b=d2H5stYFvBhbAk3Fbm1lv0nM/GuPuJUStDtQVj8C9Rpj3HhT1hY6y/EHz9cJLOnv45 KXBT7wmSw0YWPK1lYznxtFOWMtaX8aPRzw2D/nqqlRaeCAal++bPdzb4pIplzf4jaaSA C8x1vX8u/Z8lBBWiain5DzPVp91IJO8MyanTK6iREfHYXywy0V1MpRAe2pLFAiPJS1EI JHOMsy3NOrtQhoMzWiqoLv/MQ7YP/0Bup4C3pZijnUs5clMmmZSkAK5SgXfTYwNm8+mW 5bPB7pKhVAocQ12CuS4uFi2TEkpBFasNsDStrWGdUoE9GrXUlikgx0kXHi3AkjJ9jgxm d5Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=3osXuZPM0CIjpDvKOd2/eycIEGooDm3rDaaca3FvesI=; b=nPyN1xMAcrE8UmU8IQwUv7m5SCJV+oQFGg0TTope4zD6D2/W0RdxW9SJBvMifimCx2 iCSLOjlWrQGmDvtFxeiv83nYv8tZdLVFj7pWaRdEGneqnvkqRdqlK9GO8rrAIKvkGyO6 CFFFRHbn5fXRk/gjhTRA9uT5bVFpMz1Tk+3CUSzAjWZaInnY7SCube9BvB91O9SWypJw OTM2wCPAL06aVbuJVEAtW6byT8BIi7wMmxp10XoV3lxVP+kj6ujvdza+LPt8vU4BcJo8 GwVpZ9D4D37oUy2BM5X9hgtZbfelCal6X9vt9vveDwc2RTHx2WiARqg2r5iTBTXCgCih 3T6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@grsecurity.net header.s=grsec header.b=YTslvDp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=grsecurity.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si10744322iln.165.2021.11.05.07.47.22; Fri, 05 Nov 2021 07:48:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@grsecurity.net header.s=grsec header.b=YTslvDp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=grsecurity.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233267AbhKEOrK (ORCPT + 99 others); Fri, 5 Nov 2021 10:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbhKEOrJ (ORCPT ); Fri, 5 Nov 2021 10:47:09 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8BEC061714 for ; Fri, 5 Nov 2021 07:44:30 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d5so14139866wrc.1 for ; Fri, 05 Nov 2021 07:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grsecurity.net; s=grsec; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3osXuZPM0CIjpDvKOd2/eycIEGooDm3rDaaca3FvesI=; b=YTslvDp5Fgvn8LLdp3Kq7jQlUD+dztLUGHFKNc30WlVQAYj08qHDmCXxHCrROpKHFh jaWBSdxF8ppWLqQFUPDs+NfikZOESMyqVeY0K0PGZK1P6774pTgr8j5SEL/kCEdZx8OU KHRtEvIQFZyqphq2NtrKMgO28Htk4i3/M5tX8GjRj24KkDQ/i7iqp9/vWagYgZ4gtyZz asTC9jNsEOev1KzQIBG94Z3I3EcCXwT8pKd1UQGrpNLxWpIsX0MIjOoQGh3DsrYZ8mOk 0kXjwHEY7OneGuZ2KZo7tCOuBL2dtfHF1tSIGowUDf8WJ9KzEUzeOVVLJd/oEaga7Y/6 zOqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3osXuZPM0CIjpDvKOd2/eycIEGooDm3rDaaca3FvesI=; b=s2D+rbICAw5CHrGg4Ivn6yG7iv7zgOMUE4hpcZyrFNaqJeW3Bc0QF8Li9w85ldwJ7J uj5lsK05yXFhiJ3ZohSH4jkgSKZI2+V9Rsdvq8gwcWLiV4EWnUKGLjmuPUHAQUjD4idI GMzWIEY/VLQm5BYigKt+w03lSCf92OgxE7GS1LkaWkI98CdxyJUatFMqSDvA9AjzYRRO eExbC3ODxjjkl1jNLEuQ5yc96PtI53VVfFa+VIa5Bi7g/FEFWeFQ6uaeOH3m2/JTXQJ6 3KX3onVCIo5SFUDVfaarCkYJKBX0T1ykbZ3xPkNpbKsk1OuZTG/MKbd4wbks9//oCQWS cJXg== X-Gm-Message-State: AOAM5322jNAJRLeMCXRPmU+EHs17IY+WH44mcv9nKWRvC4QTVbIzkh2+ 9/E9M10MZkl9nk5Kqtqd9+jljw== X-Received: by 2002:adf:dd0a:: with SMTP id a10mr21654919wrm.60.1636123468823; Fri, 05 Nov 2021 07:44:28 -0700 (PDT) Received: from ?IPv6:2003:f6:af04:5300:7c00:c62b:b3aa:158b? (p200300f6af0453007c00c62bb3aa158b.dip0.t-ipconnect.de. [2003:f6:af04:5300:7c00:c62b:b3aa:158b]) by smtp.gmail.com with ESMTPSA id c15sm7896981wrs.19.2021.11.05.07.44.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Nov 2021 07:44:28 -0700 (PDT) Subject: Re: [PATCH] sched/fair: Prevent dead task groups from regaining cfs_rq's To: Vincent Guittot Cc: Benjamin Segall , Ingo Molnar , Peter Zijlstra , Juri Lelli , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, Odin Ugedal , Kevin Tanguy , Brad Spengler References: <20211103190613.3595047-1-minipli@grsecurity.net> From: Mathias Krause Message-ID: <8f4ed996-e6e5-75f4-b5fa-dffb7b7da05b@grsecurity.net> Date: Fri, 5 Nov 2021 15:44:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 05.11.21 um 15:25 schrieb Vincent Guittot: > On Thu, 4 Nov 2021 at 18:37, Mathias Krause wrote: >> >> Am 04.11.21 um 17:49 schrieb Vincent Guittot: >>> [snip] >>> >>> Ok so we must have 2 GPs: >>> >>> list_del_rcu(&tg->siblings); >>> GP to wait for the end of ongoing walk_tg_tree_from : synchronize_rcu >>> in your patch >>> list_del_leaf_cfs_rq(tg->cfs_rq[cpu]); if on_list >>> remove_entity_load_avg(tg->se[cpu]); >>> GP to wait for the end of ongoing for_each_leaf_cfs_rq_safe (print_cfs_stats) >>> kfree everything >> >> Basically yes, but with my patch we already have these two, as there's >> at least one RCU GP between after sched_offline_group() finishes and >> sched_free_group() / cpu_cgroup_css_free() starts. >> >> So we either use my patch as-is or move unregister_fair_sched_group() to >> free_fair_sched_group() and use kfree_rcu() instead of kfree(). Both >> approaches have pros and cons. >> >> Pro for my version is the early unlinking of cfs_rq's for dead task >> groups, so no surprises later on. Con is the explicit synchronize_rcu(). > > which blocks the caller and could be problematic > > It seems that LKP has reported such issue: > 20211104145128.GC6499@xsang-OptiPlex-9020 Heh, indeed. >> >> Pro for the kfree_rcu() approach is the lack of the explicit >> synchronize_rcu() call, so no explicit blocking operation. Con is that >> we have cfs_rq's re-added to dead task groups which feels wrong and need >> to find a suitable member to overlap with the rcu_head in each involved >> data type. >> >> Which one do you prefer? Looks like it needs to be the kfree_rcu() one in this case. I'll prepare a patch. Thanks, Mathias