Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp341525rwl; Wed, 9 Aug 2023 15:42:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5QV88IKICZZulFHFgS3GhsUhxk6mml5BGeeyqFaKs+AyUbdz6gl6r7qJ5Hc4+Kv8jlMVu X-Received: by 2002:a05:6a00:1744:b0:682:4c1c:a0fc with SMTP id j4-20020a056a00174400b006824c1ca0fcmr710209pfc.19.1691620920616; Wed, 09 Aug 2023 15:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691620920; cv=none; d=google.com; s=arc-20160816; b=dQp/lP5KEGqRET5L+FCaldU+AmxHncondU4rMAH3WE2LtmCAakgvkp7fIc6K2T9/+c ZkmVA5Hwa4tBiWQQ/lA7f0i2VMZyMw6SHTJ1/AdZ1da2uAE8MZD8ydOiWdzc8yPn9R8g ONZFQZfLmnqEENyOJa4eF1FSyXyJ9KuTQa6EqIy7TClaDQZ36YNuvzZTf2L9OTirO0DE xnSQk7IIWVLPSUI5wwfVGM4ZolZL6dX8XbcGDJTEbUKVvtnndEiB4Sx4nrqDXjTwOJ5F 58kaWnfCTlaiCs5e/q/IrDMr+rgUkdaHZFq5AgXsCd3o5vLGJSF6jvGEQljmvrH2EZKj PJJg== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=//xuUqEbAoChMqlkpflQb6XFF+UhgSuCsR64Dz8oIOw=; fh=3rH7KRj82VGxYNHs6tr3wudv8eB4uDqtOMfB9yRgNk0=; b=pea6dwzCNyI0ryZrLdKCuf2/jbtHtYK61PcRlLl7jQrUx1qWaucRRdeN6cQK/Y93KG a8HuAoAxyRy87hT5uJ9//we2imfXeeJ0SsQs6Buj5/uhJ3CvEYhvAjUFfGAbG1Nvj7uu 9VrWQeJKa7Y5eO0CL2vFLWTYAG/y13zjIg0wuZS3oOZd56vfLr3/e9N8nyJyLSiOtEsc HwoyKaDZjEjWIRVUHM0Fx4qztCzQZ/BPAAC7i8BBI1Gdup/1QArDNf3prq0WkWVJWw08 hrlS9A+DtdSxHk/isJhmElOyRqCNJt+ZkKXPfP/bcBJGS+88u0tUAeHB9QQ3ZEWjUsg4 TAfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=RufX4Pgd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dw19-20020a056a00369300b00686e4b20b67si192743pfb.268.2023.08.09.15.41.48; Wed, 09 Aug 2023 15:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=RufX4Pgd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbjHIWZd (ORCPT + 99 others); Wed, 9 Aug 2023 18:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjHIWZd (ORCPT ); Wed, 9 Aug 2023 18:25:33 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FF9B2; Wed, 9 Aug 2023 15:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=//xuUqEbAoChMqlkpflQb6XFF+UhgSuCsR64Dz8oIOw=; b=RufX4PgdOl7/nn1WfR4xMKanOl D8ramvykvo45vHnoc+ju2imszAJPNbvtFdVL0OAfTekgQwwA2HBM3O4RyiDQpaRRNM/2kqS4u4SmG YwKohVEgznE3HYd0qC2ScNMZxaFBGA5NkQUwLMYG2eTgldeeOQHQlWYD98Ym40vjOQsny+efBjxpc 0P0JA7rgEa0usmHDtYv85YIiTyIQzg5ThDrQMn8xVUCCsF7KFw1AslC2RHbmnlzeh9t2ZgwSG2B9c CsDCPXpSHkA9MheAvKSZSV/fFKyMjeyJHm+/VdJLiZKwvNgVK0zS633u+Cv7gN5lEt4OKitHigi+u SmbFSjYQ==; Received: from [191.193.179.209] (helo=[192.168.1.111]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1qTrcL-00GDvY-H2; Thu, 10 Aug 2023 00:25:25 +0200 Message-ID: <071c02ae-a74d-46d8-990b-262264b62caf@igalia.com> Date: Wed, 9 Aug 2023 19:25:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 05/14] futex: Add sys_futex_wake() To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, tglx@linutronix.de, axboe@kernel.dk, Andrew Morton , urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, Arnd Bergmann , linux-api@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, malteskarupke@web.de, Geert Uytterhoeven References: <20230807121843.710612856@infradead.org> <20230807123323.090897260@infradead.org> Content-Language: en-US From: =?UTF-8?Q?Andr=C3=A9_Almeida?= In-Reply-To: <20230807123323.090897260@infradead.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Em 07/08/2023 09:18, Peter Zijlstra escreveu: > To complement sys_futex_waitv() add sys_futex_wake(). This syscall > implements what was previously known as FUTEX_WAKE_BITSET except it > uses 'unsigned long' for the bitmask and takes FUTEX2 flags. > > The 'unsigned long' allows FUTEX2_SIZE_U64 on 64bit platforms. > > Signed-off-by: Peter Zijlstra (Intel) > Acked-by: Geert Uytterhoeven > --- [...] > +/* > + * sys_futex_wake - Wake a number of futexes > + * @uaddr: Address of the futex(es) to wake > + * @mask: bitmask > + * @nr: Number of the futexes to wake > + * @flags: FUTEX2 flags > + * > + * Identical to the traditional FUTEX_WAKE_BITSET op, except it is part of the > + * futex2 family of calls. > + */ > + > +SYSCALL_DEFINE4(futex_wake, > + void __user *, uaddr, > + unsigned long, mask, > + int, nr, > + unsigned int, flags) > +{ Do you think we could have a if (!nr) return 0; here? Otherwise, calling futex_wake(&f, 0, flags) will wake 1 futex (if available), which is a strange undocumented behavior in my opinion. > + if (flags & ~FUTEX2_VALID_MASK) > + return -EINVAL; > + > + flags = futex2_to_flags(flags); > + if (!futex_flags_valid(flags)) > + return -EINVAL; > + > + if (!futex_validate_input(flags, mask)) > + return -EINVAL; > + > + return futex_wake(uaddr, flags, nr, mask); > +} > + > #ifdef CONFIG_COMPAT > COMPAT_SYSCALL_DEFINE2(set_robust_list, > struct compat_robust_list_head __user *, head, > --- a/kernel/sys_ni.c > +++ b/kernel/sys_ni.c > @@ -87,6 +87,7 @@ COND_SYSCALL_COMPAT(set_robust_list); > COND_SYSCALL(get_robust_list); > COND_SYSCALL_COMPAT(get_robust_list); > COND_SYSCALL(futex_waitv); > +COND_SYSCALL(futex_wake); > COND_SYSCALL(kexec_load); > COND_SYSCALL_COMPAT(kexec_load); > COND_SYSCALL(init_module); > >