Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1091602rdb; Wed, 1 Nov 2023 11:01:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9Ggfd9kRqt/vKj7UjKCoEJst19N/pwlIthiaQdffiprCgF8anws8lQjgDfXIh+131r5Q7 X-Received: by 2002:a05:6870:2a43:b0:1d5:8d6a:18f0 with SMTP id jd3-20020a0568702a4300b001d58d6a18f0mr3930738oab.27.1698861690709; Wed, 01 Nov 2023 11:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698861690; cv=none; d=google.com; s=arc-20160816; b=RQQOHqDB+86x9NZXakkoOdLt8+gw411QM6EGU5yeHCU0FmDMcJ7KsY2g4OmceA5JIk dI+Hcmj3rWa2RGDWhgVjnGd6iuKAfLot5bXgaVP870n4Aq9sfpUB7e9NOkXHiweaJDCk AE8ngq2jf3CG5UT3mBnLYqgoqj5JjImVjBfCw2IbM5p3Stv/YSnuGCp0tDJdZEgiGfkQ 0R+W+ssNhgBk1KAib4JYI/tvzfMHZVOdct06ZxlvWZ8Y/GvNorSMC3ZOCmqwrHSHkj4o l2Rau80cr+kR+csUMkmCMdNq9fgMbkdakapdzyVJ5fq3NMBcZTg3lwvBZNOHl8gW6g77 bY8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KYk0tSjsrn4HcNFkcNV6IhBOk/uVrvqmA+02iLrYOnk=; fh=4jCAiDdyla7ST2eOOO+ICVvpvInxET3rtTa0S+yxHO0=; b=0g9JYQux1u2a+9nDMB/xQrSD/zX5L2oJJXsPh1z0B2hHEBpDZN55q/Iiii8Lf+WSid 8ShGkBuIOzDDkZCGFL0rYovhGDecMG6FIBvl24GF0Op5KxHo2H/IMt8pF1LkBCGWLJWB v7O8UePxACUaFSuB5WyFWlXQ2xtH74u7BHx6/YZXcf+ZiATG6xxMFGsviZPGuuetz0Eq 74vDTbEBB58xVImGPloevFDUF+xT4Ck34ELEMT46dJKkPRIxFpvkdVMkjWrdMwKhqH88 AeeXXESBAWaVWVC4eTPO0Y89rGmoJf/JHM6R0Uk3v+VbrpcdOGZynmTT4qhs4bz5A8sW +QUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i7UtwFj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id wi22-20020a056871a71600b001e99f9beb7csi643866oab.198.2023.11.01.11.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 11:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i7UtwFj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6F63A8021233; Wed, 1 Nov 2023 11:00:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234060AbjKASAs (ORCPT + 99 others); Wed, 1 Nov 2023 14:00:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233842AbjKASAr (ORCPT ); Wed, 1 Nov 2023 14:00:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49982C1 for ; Wed, 1 Nov 2023 10:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698861598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KYk0tSjsrn4HcNFkcNV6IhBOk/uVrvqmA+02iLrYOnk=; b=i7UtwFj+4Q1PRmJxDIy5TGsz6Mbdmw1Z8+ZXCAHmqCNLcVH8k/T9TV7tJk8wwbxUakdxEb uHsS53ANOfZ+cEX9wOsr33oja4RPiGURWrSwKpnixbHDsYC0DD9CFHvuI2hdSOEO2ilCNW +2aLQ7wpjRQwFnkL9E1A9U/ygGxjmTA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-O4ouqYOsNNaYX_05FZqvKQ-1; Wed, 01 Nov 2023 13:59:50 -0400 X-MC-Unique: O4ouqYOsNNaYX_05FZqvKQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22A57101A529; Wed, 1 Nov 2023 17:59:49 +0000 (UTC) Received: from [10.22.33.245] (unknown [10.22.33.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id E15DA1A099; Wed, 1 Nov 2023 17:59:47 +0000 (UTC) Message-ID: <8e1b5497-d4ca-50a0-7cb1-ffa098e0a1c2@redhat.com> Date: Wed, 1 Nov 2023 13:59:47 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v2] cgroup/cpuset: Change nr_deadline_tasks to an atomic_t value Content-Language: en-US To: =?UTF-8?Q?Michal_Koutn=c3=bd?= Cc: Tejun Heo , Zefan Li , Johannes Weiner , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Juri Lelli , Peter Zijlstra , Ingo Molnar , Qais Yousef , Hao Luo , Dietmar Eggemann , Steven Rostedt , Xia Fukun References: <20231024141834.4073262-1-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Spam-Status: No, score=-5.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 01 Nov 2023 11:00:58 -0700 (PDT) On 11/1/23 12:34, Michal Koutný wrote: > On Tue, Oct 24, 2023 at 10:18:34AM -0400, Waiman Long wrote: >> The nr_deadline_tasks field in cpuset structure was introduced by >> commit 6c24849f5515 ("sched/cpuset: Keep track of SCHED_DEADLINE task >> in cpusets"). Unlike nr_migrate_dl_tasks which is only modified under >> cpuset_mutex, nr_deadline_tasks can be updated under two different >> locks - cpuset_mutex in most cases or css_set_lock in cgroup_exit(). As >> a result, data races can happen leading to incorrect nr_deadline_tasks >> value. > The effect is that dl_update_tasks_root_domain() processes tasks > unnecessarily or that it incorrectly skips dl_add_task_root_domain()? The effect is that dl_update_tasks_root_domain() may return incorrectly or it is doing unnecessary work. Will update the commit log to reflect that. > >> Since it is not practical to somehow take cpuset_mutex in cgroup_exit(), >> the easy way out to avoid this possible race condition is by making >> nr_deadline_tasks an atomic_t value. > If css_set_lock is useless for this fields and it's going to be atomic, > could you please add (presumably) a cleanup that moves dec_dl_tasks_cs() > from under css_set_lock in cgroup_exit() to a (new but specific) > cpuset_cgrp_subsys.exit() handler? But css_set_lock is needed for updating other css data. It is true that we can move dec_dl_tasks_cs() outside of the lock. I can do that in the next version. Cheers, Longman