Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp646286imw; Fri, 15 Jul 2022 10:08:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vRAlr6TBDcYqsL5sNjbeS2GQ95wpGMsfIYwkzDOTXK50DIb/5YhsQ3PNo1sfPQ3LVCrVLh X-Received: by 2002:a05:6871:14a:b0:10c:5005:a6b1 with SMTP id z10-20020a056871014a00b0010c5005a6b1mr7795099oab.191.1657904912846; Fri, 15 Jul 2022 10:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657904912; cv=none; d=google.com; s=arc-20160816; b=O8i9mAZvo1YVQ471pZ+qBds1ukEEmqDhodgwj+p5bkx7H7ckElSCBUXuIpeGFOl6WU IjG27hmqKtaXiZVe4et/tz9nKq+cEq2T1+TLBBCAP2xNOxH0XjB2lnD4IaFRbZi5/9da /HrJCyBczhFrg4ckxcD/3qdzvF4YCHr64vNq2nQMbr4QctZDzItxkDsaw+cOz/EJaW9E h4flv3cI+hWLsbR+JRrFx5n4uXqM9O2bYzTBoYBi7Pf/l8L4RqNGnyR/0OVcNr5eg0NU dFwP1gOhqvNi5JwBqfQzKMsLUPYOF81S2dyDSdlnjK2LGh9sBfAVb9IXNhBoIkLdPsZu 314g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=UwC5anEg0yjsg9Rw8IcHiu3GinY8BZcocAU9uCH0MCI=; b=G0c7aLE8rRyf5O+KWlscMx5t/W2Di/xMNNurjmkv5wtfAPXROg73KXXSsMbUT7eYr5 BosuVI+WBjFgeWOVFCxHMNzmNwn/KG04wNUvWPlqdUV4zal9Ik8enqB2caCpB1x/o366 6I5e0d/01t/cVAVrYGQkBVqFQ8gJljY6O3U55G4n4Z3PI8oXsKGtDEYd7fFfcL+/qnK7 pjy++1UMhkig8rc6ittePc7LPSkLdQAt67SdIiOp222sz0vcCX6ageLJt3kpCyci+c98 CbdHk0/wgJlXTEKqpdNhphtNucznfUsowcuv9ivyq9n/AyGGd9cxJwqOtN/eZOyrnYOL v2Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kRPX1ruM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a056870610c00b0010be09dc7acsi4297793oae.190.2022.07.15.10.08.16; Fri, 15 Jul 2022 10:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kRPX1ruM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbiGOQsF (ORCPT + 99 others); Fri, 15 Jul 2022 12:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiGOQsD (ORCPT ); Fri, 15 Jul 2022 12:48:03 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DA6B7E6; Fri, 15 Jul 2022 09:48:02 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id p9so6117722pjd.3; Fri, 15 Jul 2022 09:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=UwC5anEg0yjsg9Rw8IcHiu3GinY8BZcocAU9uCH0MCI=; b=kRPX1ruM5CjMlu1wj9auhM8ser8wATC3gVJCAiI2vCbhcBXZUWMyDTYhDsEN/2ow6z C7+1TvQrQD+ErLtFG/kwIDtsu18cPtzxGuZpGEVGPFYl3nQyigz+bLUFOvO8aqhIeQJW 4FSZJpcLxa1UNYvKt0avG7GV9ldTRpmJsArPWoQDpxzmoAeCe0mKq4oRFAnuTUE8JlYj ZBKcF2ZN1n8f1akV2/h1+4YiqKiFPWla4bdyW3gCXvq3GTO0h7JXURDp3MXRfzNjWyoz 2UzQFer9HHCToT+r6naorvjdplG/zjIyDzUKHeaM8cEww4he+LQ0Q2IQqBilO84FpZme AYiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=UwC5anEg0yjsg9Rw8IcHiu3GinY8BZcocAU9uCH0MCI=; b=lS+USKH5CXn99mTQS4TfcEWDzW1SsrVzXPvs5t9y9qsP2YWH4RLhAkmXbWMktx6qg6 Fl8Evi4oehfxEdUm2sr+FJFv/+lNHBkhgnOx5QtQ6S7fVM/vzg8PE/v2I2xnzPkRWwvo DOU0fmYW3gE6tkP9Lte6RetvT0TsxjuxLzXJ4Ns1FO3zjUTgcCbjAkw+iFTelVrbvUiO sjxaDaEXOhgm8WOBL3mGYPrMo47M70uXz+xiVJEta2r3Jj77JYm76tZneeBxSLsBRPlP aDG1EKGETY39zmTPFQxz35zaufeK365XdC6+vtf6mD++AHS9I2a+Hv8vPSXCVy3Og9el oygA== X-Gm-Message-State: AJIora/IRtWsd94mAa9s5kdaKMBZXzUl8F0POlUNzCV4DCGMT0EZ8U+i +zQDhuTrJ68p3AhpYyA6mJ4= X-Received: by 2002:a17:903:3093:b0:16b:deea:4d36 with SMTP id u19-20020a170903309300b0016bdeea4d36mr14423269plc.126.1657903681751; Fri, 15 Jul 2022 09:48:01 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id g14-20020a62520e000000b00528d3d7194dsm4123824pfb.4.2022.07.15.09.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 09:48:01 -0700 (PDT) Sender: Tejun Heo Date: Fri, 15 Jul 2022 06:47:59 -1000 From: Tejun Heo To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: Jing-Ting Wu , Johannes Weiner , Zefan Li , Matthias Brugger , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Shakeel Butt , wsd_upstream@mediatek.com, lixiong.liu@mediatek.com, wenju.xu@mediatek.com, jonathan.jmchen@mediatek.com Subject: Re: [Bug] race condition at rebind_subsystems() Message-ID: References: <1978e209e71905d89651e61abd07285912d412a1.camel@mediatek.com> <20220715115938.GA8646@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220715115938.GA8646@blackbody.suse.cz> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (resending, I messed up the message header, sorry) Hello, On Fri, Jul 15, 2022 at 01:59:38PM +0200, Michal Koutn? wrote: > The css->rstat_css_node should not be modified if there are possible RCU > readers elsewhere. > One way to fix this would be to insert synchronize_rcu() after > list_del_rcu() and before list_add_rcu(). > (A further alternative (I've heard about) would be to utilize 'nulls' > RCU lists [1] to make the move between lists detectable.) > > But as I'm looking at it from distance, it may be simpler and sufficient > to just take cgroup_rstat_lock around the list migration (the nesting > under cgroup_mutex that's held with rebind_subsystems() is fine). synchronize_rcu() prolly is the better fit here given how that list_node's usage, but yeah, great find. Thanks. -- tejun