DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 528HCHmV1560138 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 528HCHmV1560138 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=hjT143nc X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D8993858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1741453936; bh=06iBZ9q6YhloxVKV1zEl1IhdJPPcydMx7cMVyy/7YIY=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=hjT143ncm1U5Du7tEfv+2YKn7fzwhnMIrNl/UxNWpoAExWkFmIma+cFyM3n/cW8+i fBUUdxWzMnoAJeVq3D+e77uIGG/xQ4yz7K+2KfYtDN9UCYDSd7HCmxcC+EMXJZgYQd 02VBWku3JpdGDnJlMY/AQWU3XNiYI8qVrhw7E9yU= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2042E3858D1E ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2042E3858D1E ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741453875; cv=none; b=BxpKziNmh7bNe+oyBxI9SCb+U0yjff4T2FkJQAhJHhTml999gr3ZphqBFAxAf/39TIEPL+V2viO4ALJUmDPEwuH3FGDeyro8NFkY1rNcHjZwLpAnWn0SB6Lm92IywCgOid/EWJ2T8LKevhIpo7dyddNhpvZxyH0tZABdxJp8GXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741453875; c=relaxed/simple; bh=gm9DFNLGCn4+v25l2epFlwkZ1fTLTw0IHNU2rZ2zNGA=; h=From:Subject:To:Message-ID:Date:MIME-Version; b=HqaFl/00LD+SVonH7/DIkHKYKmiXWKobhk/z0sBDnABBcNEDcvBvjWOt/c1lSgM9M4QuEHR84lhmixST1antQx+7YAheWizTnSwWWIW5z6QY8seq6nqIpCkk2krQx48Dxjseej/twZYC3inx7cDw9oJjpz+Kq/x3Vt7UWM0h924= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2042E3858D1E Subject: sched_getaffinity() always returns the full cpu mask To: cygwin AT cygwin DOT com Message-ID: <378d90a0-bff5-36d1-d1f7-8a28e046af2a@t-online.de> Date: Sat, 8 Mar 2025 18:11:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 SeaMonkey/2.53.20 MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1741453867-127FB930-0D8E1352/0/0 CLEAN NORMAL X-TOI-MSGID: 6aa39363-ed97-4c24-939f-f87bb5d36605 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Christian Franke via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Christian Franke Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 528HCHmV1560138 Testcase: $ grep processor /proc/cpuinfo | tail -1 # i7-14700K processor       : 27 $ sleep 60 & taskset 0x1 sleep 60 & [1] 62094 [2] 62095 $ taskset -p 62094 pid 62094's current affinity mask: fffffff $ taskset -p 62095 pid 62095's current affinity mask: fffffff Another test shows that the affinity mask is correctly set to 0x1 by sched_setaffinity(). In sched.cc:__sched_getaffinity_sys(), GetProcessAffinityMask() is called, but its 'procmask' result is never used. The returned cpu_set is build using groupmask(__get_cpus_per_group ()) which is constant, here 0xfffffff. The original commit 641ecb07 likely worked (until 687c4bad^) on older Windows versions which did not support cpu groups. I don't know how to fix this for systems with more than one cpu group, so no patch provided. It might be needed to handle interesting corner cases: "If the process had explicitly set the affinity of one or more of its threads outside of the process' primary group, the function returns zero for both affinity masks." https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprocessaffinitymask -- Regards, Christian -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple