From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56170220F2A for ; Thu, 21 May 2026 12:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779367853; cv=none; b=VLNZl+SV7EBwK+PDxKXbo41mjd52c3ZVjhhdssmL7eNGKMsv3oiVuHmpqCJMEmiQPYVuMGvSOCIPXgCymUNtu/FkpOxbcuWGQic2rHAWF1l0W/c+BZ8Phs8PMZ/ejNW+s+QMbuisaSwY3+cB6Aezx5WoDib44AYuYspM14+9RpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779367853; c=relaxed/simple; bh=TqpAeldX4raOLsnl3M5XzqSK79/AeGipDHY/LyTvj/I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nk4xYE1CGjvTPGUUL7HEklMhE9eD/J7LzhKMNrVmXn26DPW6eB9mWNgGE+K6SysmoJuEeCjpR3KwSF7cJrdsIS0KFWuyPOLqht7n0Q9PTKPrJ/I/GzkRbuZthjPOSHFmDuyTrXZKGuJDXipn/4afzF8tuMKtL7Mr2vZ+QqLnutg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ALVKsgBs; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ALVKsgBs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779367851; 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: in-reply-to:in-reply-to:references:references; bh=KaqOGzCWcKmTXaAt0hdsUgHIDDRRrinOd79Ukai7qAw=; b=ALVKsgBsIMyhp2jWBaJHfCjDsZ2ed9q+x3Pwi5q0XsiOkwBIQRwyXVvwf7ubT0UnaUrjWm EJpAwwUFYnVMX3keXJGkjxAyQ7f4GutU7zmjOxZ/TVxq7z88gJXug6LHRlnYhxReaLuaYz Z6Y0HVpTzCvojzVbUYHi+wpxf0uUdX8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-h_lvLhz4Ma6HPQ4iBwNr-A-1; Thu, 21 May 2026 08:50:45 -0400 X-MC-Unique: h_lvLhz4Ma6HPQ4iBwNr-A-1 X-Mimecast-MFC-AGG-ID: h_lvLhz4Ma6HPQ4iBwNr-A_1779367843 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6CD518005B3; Thu, 21 May 2026 12:50:42 +0000 (UTC) Received: from fedora (unknown [10.44.48.45]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 4988919560AB; Thu, 21 May 2026 12:50:38 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 21 May 2026 14:50:42 +0200 (CEST) Date: Thu, 21 May 2026 14:50:37 +0200 From: Oleg Nesterov To: Andrea Calabrese Cc: brauner@kernel.org, akpm@linux-foundation.org, peterz@infradead.org, tglx@kernel.org, kexinsun@smail.nju.edu.cn, adrianhuang0701@gmail.com, elver@google.com, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com Subject: Re: [PATCH v2] kernel: refactor: shorten has_pending_signals Message-ID: References: <20260520062849.183621-2-andrea.calabrese@amarulasolutions.com> 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: <20260520062849.183621-2-andrea.calabrese@amarulasolutions.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 05/20, Andrea Calabrese wrote: > > static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked) > { > - unsigned long ready; > - long i; > - > - switch (_NSIG_WORDS) { > - default: > - for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;) > - ready |= signal->sig[i] &~ blocked->sig[i]; > - break; > - > - case 4: ready = signal->sig[3] &~ blocked->sig[3]; > - ready |= signal->sig[2] &~ blocked->sig[2]; > - ready |= signal->sig[1] &~ blocked->sig[1]; > - ready |= signal->sig[0] &~ blocked->sig[0]; > - break; > - > - case 2: ready = signal->sig[1] &~ blocked->sig[1]; > - ready |= signal->sig[0] &~ blocked->sig[0]; > - break; > - > - case 1: ready = signal->sig[0] &~ blocked->sig[0]; > - } > - return ready != 0; > + unsigned long ready = 0; > + for (long i = 0; i < _NSIG_WORDS; i++) > + ready |= signal->sig[i] & ~blocked->sig[i]; > + return ready != 0; > } Note that with your patch the main loop doesn't stop when ready becomes != 0... OK, I guess the modern compilers doesn't need this hint even if _NSIG_WORDS > 1, so Acked-by: Oleg Nesterov But since your patch is just a cleanup, you could do for (int i = 0; i < _NSIG_WORDS; i++) { if (signal->sig[i] & ~blocked->sig[i]) return true; } return false; but this is subjective, I won't insist. Oleg.