From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FD4619CCF7 for ; Sun, 19 Apr 2026 18:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776622264; cv=none; b=G9zUo4pPvrwPj4b/Ll/xNs0hv7rzJXlqVpo9JsWecdxf4UvLrJpdG83pV5nZQSB/4aTzeuKVkT8XYFPSPGlNiRJ1qMEpey2NjZjHOcmImJfzMi8BCzLulB0rx2eBCS9LykmofHDSuzyZ1OkSk0Z3ntYeEpIxX57MzYeTVgao/4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776622264; c=relaxed/simple; bh=vaop3+tKUYG+OFHgFaxjNNUoFa+r1iuv4qVKaUQdM3E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qEOmnxGQha6oPHkIkqrqY79WTAS6sUahqxcUUCF1gzTlLQVNlGoKiwXbOanrMXFSd9o/dJ/9vy5CXDh7iS+LVCy5WOIhiuaCUjkunG4I445Wj/W/Hz5VJv04Qt3smOvB2EfLHUjVLYhQTYPfDcYxrpUO7Uwb50C2SEIcA9pqVbo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O0MS6ttq; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O0MS6ttq" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2aaf59c4f7cso9415325ad.1 for ; Sun, 19 Apr 2026 11:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776622263; x=1777227063; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LVsyHUcW/CGIzBJe8BryrCxfCjSbQMtYSPcW16KpKLk=; b=O0MS6ttqhkxRT1yb6X+qG7bTK1vzK6RebPorOQUXeQRqdx4MrmAEDNNYbP1XTL/dmv gxb32/gYta8B6GPDtAc1e7hvv5UHkOMCTfIaqFiDu86crtqV/GSKnFlLiEr2smKrTi2q thvVzcpNGws3/lmuTzAoYT4rF3drCC+uGdtCfvOrOqEjXR9V5KK6ArovNmtfIMQo4Lui J+ciNK4LQfbJpm51Ld6i+zKc1w9lw5upjmg0ZzDPfhaZQLvefOxBeXvcg8P60ioAVpxW IWrXuKsOKGwQHP4dB7qoMAlZKADiuleR1akiXu7oIAgJODZ0V4HxyQBljKMM85jdvBPy m2sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776622263; x=1777227063; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LVsyHUcW/CGIzBJe8BryrCxfCjSbQMtYSPcW16KpKLk=; b=U5oY2l8M9MkQwVhNrDJZoFNZzrKW3ti5uG0HehLjGbKZGKJwC1AMH53PhXysZyRVNY gQSFpGdqLkyK4CMGkJq8pw4Mx/d5ZnE1m1OoFX845vR+JQJmH3dw98JV2bB2cdAMI1FU Wp+1ioD0sOrqlh6MVklBBY3bZfKQga9630zq4rXQLN/bg666WEDn/wbOnU/Cl62iN7uP xUh4KJCY+ldTynI7Ob1Yuyr/0qlPNpN1Uw8e9i1Z+3okNXfKfyDrb6z7ggJwJujswc8J J8u6wbiJlwaJWBFlgoJ7D9P7ZEryG7M79UyIM5BZ6swIjsNeArfnroaj0B+vClg/6xEp dwsw== X-Forwarded-Encrypted: i=1; AFNElJ/bdkrkanK9WQYB2+2r7tZVA/dIK0MxfXszlTt/O07la/YhlunYH0mrFnfMXo5pI1jEBm8fD+vobeO1Fqs=@vger.kernel.org X-Gm-Message-State: AOJu0YyBA2KGEJC5C0FLMuriO+HHMBm5nuvFht1XwLn+YhItNA0a//zM BvUoMk+VOPIND38imfd9gu6ThtSJ4TKEHpFO9MLWrZrEkXRUKdwx8HRD X-Gm-Gg: AeBDieuQFgSxkB4LweEFalCIpUgUnDFroLL88TP5+ZfCRpEL+w+s7hjTpEApyF16PWs Dhcp35pn5vfqWji/RYJQAU26UED29PCV2gDCg3xR6GAuMfO9TSY3PO5uP0OxphAn5YMQivHAVBB XINZS3HrKD5PKqsKSIwKMP0V6U7dwCSPKNGk+xbaLAxNnMXWwcoRn7Va9Zvaz2B0D+b1Ydb/jr2 dp5XIYH219VxCStWlBCf/VUBQa8FUixz1Vj0n2amMrwxQY18oe6KxeUnEsLugIAegbkEL0eGpR1 kZ7VzHiE9/j+vll6U3I1CWEIyRvb7COx8XWspsG4A3Rh8kfOnehCtlj3h86pphZaZkkR5nw3W0z UDPYKJlzn1zXO0RO2cYThV9PLs/owsd0pjx9dof6rb5eY3L+tS0C2Ry8X90+0oYkz3FzBFcLh/W WtfwWAPAgfEIj6WwuSXDsDE3e7rjHg+BSsj+fRzb59XBx3u5h+tzAxSjBBe0mlVyaikPdKyoCyD 1E5sEo9XnimuLyv X-Received: by 2002:a17:903:3d50:b0:2b2:596d:594 with SMTP id d9443c01a7336-2b5f9e8cda7mr71551705ad.13.1776622262769; Sun, 19 Apr 2026 11:11:02 -0700 (PDT) Received: from cchengyang.duckdns.org (36-225-119-66.dynamic-ip.hinet.net. [36.225.119.66]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab40786sm85364565ad.79.2026.04.19.11.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 11:11:02 -0700 (PDT) Date: Mon, 20 Apr 2026 02:10:58 +0800 From: Cheng-Yang Chou To: Tejun Heo Cc: David Vernet , Andrea Righi , Changwoo Min , sched-ext@lists.linux.dev, Emil Tsalapatis , linux-kernel@vger.kernel.org, Ching-Chun Huang , Chia-Ping Tsai Subject: Re: [PATCH sched_ext/for-7.2] sched_ext: add p->scx.tid and SCX_OPS_TID_TO_TASK lookup Message-ID: <20260420015438.G7a71@cchengyang.duckdns.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Tejun, sorry for the noise On Sun, Apr 19, 2026 at 06:18:46AM -1000, Tejun Heo wrote: [snipped] > void scx_pre_fork(struct task_struct *p) > { > /* > @@ -3682,6 +3732,8 @@ int scx_fork(struct task_struct *p, stru > > percpu_rwsem_assert_held(&scx_fork_rwsem); > > + p->scx.tid = scx_alloc_tid(); > + > if (scx_init_task_enabled) { > #ifdef CONFIG_EXT_SUB_SCHED > struct scx_sched *sch = kargs->cset->dfl_cgrp->scx_sched; > @@ -3717,9 +3769,13 @@ void scx_post_fork(struct task_struct *p > } > } > > - raw_spin_lock_irq(&scx_tasks_lock); > - list_add_tail(&p->scx.tasks_node, &scx_tasks); > - raw_spin_unlock_irq(&scx_tasks_lock); > + scoped_guard(raw_spinlock_irq, &scx_tasks_lock) { > + list_add_tail(&p->scx.tasks_node, &scx_tasks); > + if (scx_tid_to_task_enabled()) > + rhashtable_lookup_insert_fast(&scx_tid_hash, After reading the review from Sashiko [1], should we handle insertion failures here? ret = rhashtable_lookup_insert_fast() if(unlikely(ret)) scx_error(...) > + &p->scx.tid_hash_node, > + scx_tid_hash_params); > + } > > percpu_up_read(&scx_fork_rwsem); > } [...] > + /* > + * Insert into the tid hash under scx_tasks_lock so we can't > + * race sched_ext_dead() and leave a stale entry for an already > + * exited task. > + */ > + if (scx_tid_to_task_enabled()) { > + guard(raw_spinlock_irq)(&scx_tasks_lock); > + if (!list_empty(&p->scx.tasks_node)) > + rhashtable_lookup_insert_fast(&scx_tid_hash, Same here, thanks. > + &p->scx.tid_hash_node, > + scx_tid_hash_params); > + } > + > put_task_struct(p); > } [1]: https://sashiko.dev/#/patchset/a19c8c74d7c767bc9865b75d6de7c723%40kernel.org -- Cheers, Cheng-Yang