Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp757926rdg; Thu, 12 Oct 2023 23:10:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUKeuk/KhShP/tMvuHmZGwUbA0503vResvwh+2tjepPrykZjCLOMFSbj7JDzrR2n+PBJ+D X-Received: by 2002:a17:90b:4b4d:b0:278:fb87:43e3 with SMTP id mi13-20020a17090b4b4d00b00278fb8743e3mr25544136pjb.12.1697177440409; Thu, 12 Oct 2023 23:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697177440; cv=none; d=google.com; s=arc-20160816; b=NYAt/kDPsetJ4GOJ5hQFfY5HvbtjjRF66CjE7ApLUQOS95VEenw7zngPZkYviI4me8 C7tlcwEGIf8v+ywONlM99sk/j1wKaY/izCIs6drMoDElXKaJJxlZhJYQ9HspNdMM+W0f nwR/CpHrrFuRXnr1l//Kc0z5fkgLokuAgY4Ws93Jn1Ql2KkUPCixY2dhBMerrUvEUfZC dLVVku4u0D8GccNrSLGpNZPfy2ngNYyCKJsN1R/k4AQUphxiv89jv0RH3Yq3nTUc+1aP TMdzEdX4YEcbjawLtp8JWFzpaZ7d4a3d+PZy/yujdp1zPy5epGM40dmanZHvIxaszaTd pDBA== 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:dkim-signature; bh=TdKa29R/s7p3SCM8FO+OVeTHJOkKpc2DM547C4oMUjs=; fh=cfSfhHiWDabg6IjUATi/e1xQsXjlXMLhHRZNIJWUaXw=; b=R+pFWS341V6ABNIf3qiUcCG3eXbvmqGT3qLgQ6SDnMjO6nJZrqbX9YHRyPV4bgYIzM JDqCs8Tfk1SJzF2Exh8u2Cw/LsIy5bwvdWNJbGugsAzNl5kgCqSVEHyYiqK+X7vG6e/u QnrZFfa4IfvyPT9i2JfynBiacnsG645CBq5wYCWRV1zd3weaIg0YFZkWtY73wIqOkI/v 1DggmgW5a6naU8vJ0vsyKBmpEbbvXn2vs4H1PO8KKheYV0Zelg45TEfqHFuNTeOy2S8m SlLZBdc9UKBQIrbyR7dx6v2ydf4n8ynxDbHGjWFw6BUbnLdLDEIvGSvMvFRlN7yXQLgv nMwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bd2nAkb7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id oa6-20020a17090b1bc600b0027cef9ad081si4294274pjb.164.2023.10.12.23.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bd2nAkb7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 1A10780BD77E; Thu, 12 Oct 2023 23:10:38 -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 S229743AbjJMGKJ (ORCPT + 99 others); Fri, 13 Oct 2023 02:10:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjJMGKG (ORCPT ); Fri, 13 Oct 2023 02:10:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C24C9 for ; Thu, 12 Oct 2023 23:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697177357; 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=TdKa29R/s7p3SCM8FO+OVeTHJOkKpc2DM547C4oMUjs=; b=bd2nAkb7vh1it4hAyNOfDiq4g11Nvhgn1v/DQyE1xqs8o8RYetgVEwhY/JuUKi6LhBVufg VTaDrxE4hf9VkLhmJGCVSkXYeEXutVZIS01tvdIuwBxBpc9/bs827pqH5r5mpk8fn5Ip0/ tcdR3vhOOGOrq8HAL2bv180OgMbfPVU= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-NzoDNIGjNQmRQnvuPysP0w-1; Fri, 13 Oct 2023 02:09:15 -0400 X-MC-Unique: NzoDNIGjNQmRQnvuPysP0w-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6557c921df1so16782886d6.2 for ; Thu, 12 Oct 2023 23:09:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697177355; x=1697782155; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TdKa29R/s7p3SCM8FO+OVeTHJOkKpc2DM547C4oMUjs=; b=oXNYEouIAalMEH6d5dJWPkpxaO/rDa/xXJflEwypHqfzBu+cmIbIa0eUv+AFhwRobq AoZbJv4utcFo7hVTzbxonftJHqXNrefzDilygj7ytEoQKUj3FetBQ9i2XFeIEQnzsHkL iiQrZwu4pHmD8SOusd7iR4SWBtNV2gbVXaMHT3nThBzLbztJ0+mpYSIDy0ewciH153on BWai42RbR/ZBPOoctdvOsdmZ4VeqBKErq5qhZ5ukGErZ2TcWkhmG0XtaAV4fkJ7WDfXD letjR8ybvOMxKP0JdyFdDvNh8/FsATNE6JUoEImiPSH9tmSR4kp9D41DEFwlpGIPqcPf ON4A== X-Gm-Message-State: AOJu0Yzdgi09F/qayMpPMB73PBb9fYsfoicWAhNgEcELfMKBnu3n+IQQ M/90xMYm+4IXEvh2NB/FVrG/VYCweVazxl55YMRVuVqcFShtiNwiPh0a8O1eiq4uiMjY6menXon iUIfEtAUrjppUWZUGziCQPpCP X-Received: by 2002:a05:6214:2582:b0:66d:2140:1f88 with SMTP id fq2-20020a056214258200b0066d21401f88mr2318762qvb.5.1697177355447; Thu, 12 Oct 2023 23:09:15 -0700 (PDT) X-Received: by 2002:a05:6214:2582:b0:66d:2140:1f88 with SMTP id fq2-20020a056214258200b0066d21401f88mr2318741qvb.5.1697177355096; Thu, 12 Oct 2023 23:09:15 -0700 (PDT) Received: from localhost.localdomain ([151.29.94.163]) by smtp.gmail.com with ESMTPSA id dm9-20020ad44e29000000b0066d15724ff7sm419693qvb.52.2023.10.12.23.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:09:14 -0700 (PDT) Date: Fri, 13 Oct 2023 08:09:09 +0200 From: Juri Lelli To: Waiman Long Cc: Tejun Heo , Zefan Li , Johannes Weiner , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Qais Yousef , Hao Luo , Dietmar Eggemann , Steven Rostedt , Xia Fukun Subject: Re: [PATCH] cgroup/cpuset: Change nr_deadline_tasks to an atomic_t value Message-ID: References: <20231009191515.3262292-1-longman@redhat.com> <6b769316-6434-5054-43f5-7933fc2bee01@redhat.com> <31e06652-1dbd-e32f-3123-d17e178c5c27@redhat.com> <389a8abc-7f0f-7bcc-bc58-f70f045d00a5@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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]); Thu, 12 Oct 2023 23:10:38 -0700 (PDT) On 12/10/23 12:35, Waiman Long wrote: > On 10/11/23 08:54, Waiman Long wrote: ... > > We can argue that there can be racing between cgroup_exit() and the > > iteration of tasks in cpuset_attach() or cpuset_can_attach(). An > > rcu_read_lock() is probably needed. I am stilling investigating that. > > Cgroup has a rather complex task migration and iteration scheme. According > to the following comments in include/linux/cgroup-defs.h: > > ??????? /* > ???????? * Lists running through all tasks using this cgroup group. > ???????? * mg_tasks lists tasks which belong to this cset but are in the > ???????? * process of being migrated out or in.? Protected by > ???????? * css_set_lock, but, during migration, once tasks are moved to > ???????? * mg_tasks, it can be read safely while holding cgroup_mutex. > ???????? */ > ??????? struct list_head tasks; > ??????? struct list_head mg_tasks; > ??????? struct list_head dying_tasks; > > I haven't fully figured out how that protection works yet. Assuming that is > the case, task iteration in cpuset_attach() should be fine since > cgroup_mutex is indeed held when it is invoked. That protection, however, > does not applied to nr_deadline_tasks. It may be too costly to acquire > cpuset_mutex before updating nr_deadline_tasks in cgroup_exit(). So changing > it to an atomic_t should be the easy way out of the potential racing > problem. My biggest perplexity is/was still about dl_rebuild_rd_accounting() and cgroup_exit(); I wonder if the latter, operating outside cpuset_mutex guard, might still be racy wrt the former (even if we change to atomic_t). However, looking again at it, dl_rebuild_rd_accounting() operates on css(es) via css_task_iter_start(), which grabs css_set_lock. So maybe we are OK already also for this case? Apologies for being pedantic, but we fought already several times with races around these bits and now I'm probably over-suspicious. :) Thanks, Juri