Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp225794pxb; Mon, 13 Sep 2021 17:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw/MyhWqAJrX32KSxcumbELcIs1gWtNYr9/0lVdNG+hKvfWt/jU0qAO23NsB3aAxjvaepr X-Received: by 2002:a17:906:26c4:: with SMTP id u4mr15356985ejc.511.1631580009011; Mon, 13 Sep 2021 17:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631580009; cv=none; d=google.com; s=arc-20160816; b=Jblj4clQtC3bR3PuYt7FQpEPffzn+uTpsGYeeElWXAAWZwGsdWUaHGLLEVnBsKmTT4 xLwK27SaYrFPGcYpd1VVdHsnFOiuCx/yTNHrhMr+oS0iUJ93JBX1EE85TWfQztHcWy/T ZNV9x4vmm5tuBiO2vDlYWNVpfL4QzK6oWgwrLd/EOy4kNi6z0nKHPQtjr+nljf7dmH75 oDR30WcXNPoY61x8eJQS5OaYLJfunebZGIlutdaxgucsYs7sJC6LULvubPEubuCPDRxH FWsuXv5VvS69DMYEe/d58wPgmzD8NbCBmYHJAvaboyrQeV0WF4otgwwuMMcGH9VTCnBl NSOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=V7twJwM4PhCAu/6IhOjA346MNvtqV4r43Qxb7zI62kA=; b=sxkX0CUKUiEw9wxon31tRnAfLbAg9JQJm6zBAMNAiaafQQkopvGjuQY1xg2mhlZPxn zD1pTJJ9QT93yHcqv9LEgx4nE2zyUjufHtmeCeKTOo04NtWmKSD7M2SBM/FXqKubWlzt U3On+HF3trtChSCtfN5BjkapcoqJKJBUDedHlFsEJrNeQcfKz8rJ4sOkWGvFufMfLU/g q8sIA6aJd34PtsP5pJ3ZRUeYqEYZSktI/qDJlEHTxtxL+IBX68ZfSHUanj7znCFYAZkC MeoS2/tD4TMojyuuzyKoPsy9i2q4d/s6wcp7TpmnhkPkF6TwepoZkcFc5jLtvCOTiErl uY8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eEnD/k4H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q30si9072399edi.509.2021.09.13.17.39.45; Mon, 13 Sep 2021 17:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eEnD/k4H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbhIMPpv (ORCPT + 99 others); Mon, 13 Sep 2021 11:45:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54776 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244469AbhIMPpk (ORCPT ); Mon, 13 Sep 2021 11:45:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631547863; 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; bh=V7twJwM4PhCAu/6IhOjA346MNvtqV4r43Qxb7zI62kA=; b=eEnD/k4HMjkpYpJCOp7dztcZMqovnNEl0yMovZDGGV4Bk5LNlGFP51vsSqeoesSXH08xwk QQW6zEqHJ/FjVgYcCLljZ+0V3PjNxACl0XrUrbbEYbVbE0BjAkUeuqiqV1s3hT44Def9Vn SQKdDWCb0T8tuJ/kC1XX5febG+qPg/I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-1VMFl39vNV2EE0DCDLLoEA-1; Mon, 13 Sep 2021 11:44:21 -0400 X-MC-Unique: 1VMFl39vNV2EE0DCDLLoEA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A4111006AA2; Mon, 13 Sep 2021 15:44:20 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A2C25D9CA; Mon, 13 Sep 2021 15:44:17 +0000 (UTC) Date: Mon, 13 Sep 2021 17:44:15 +0200 From: Eugene Syromiatnikov To: Jens Axboe , Pavel Begunkov Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, "Dmitry V. Levin" , linux-api@vger.kernel.org Subject: [PATCH v3] io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items Message-ID: <20210913154415.GA12890@asgard.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The items passed in the array pointed by the arg parameter of IORING_REGISTER_IOWQ_MAX_WORKERS io_uring_register operation carry certain semantics: they refer to different io-wq worker categories; provide IO_WQ_* constants in the UAPI, so these categories can be referenced in the user space code. Suggested-by: Jens Axboe Complements: 2e480058ddc21ec5 ("io-wq: provide a way to limit max number of workers") Signed-off-by: Eugene Syromiatnikov --- v3: - Constants are named in accordance with the suggestion, the internal enum is no longer touched, BUILD_BUG_ON checks are added. v2: https://lore.kernel.org/lkml/20210913104101.GA29616@asgard.redhat.com/ - IO_WQ_ACCT_NR is no longer exposed directly in UAPI, per Jens Axboe's suggestion. v1: https://lore.kernel.org/lkml/20210912122411.GA27679@asgard.redhat.com/ --- fs/io-wq.c | 5 +++++ include/uapi/linux/io_uring.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index 6c55362..3d21568 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "io-wq.h" @@ -1287,6 +1288,10 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count) { int i, node, prev = 0; + BUILD_BUG_ON((int) IO_WQ_ACCT_BOUND != (int) IO_WQ_BOUND); + BUILD_BUG_ON((int) IO_WQ_ACCT_UNBOUND != (int) IO_WQ_UNBOUND); + BUILD_BUG_ON((int) IO_WQ_ACCT_NR != 2); + for (i = 0; i < 2; i++) { if (new_count[i] > task_rlimit(current, RLIMIT_NPROC)) new_count[i] = task_rlimit(current, RLIMIT_NPROC); diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 59ef351..b270a07 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -317,13 +317,19 @@ enum { IORING_REGISTER_IOWQ_AFF = 17, IORING_UNREGISTER_IOWQ_AFF = 18, - /* set/get max number of workers */ + /* set/get max number of io-wq workers */ IORING_REGISTER_IOWQ_MAX_WORKERS = 19, /* this goes last */ IORING_REGISTER_LAST }; +/* io-wq worker categories */ +enum { + IO_WQ_BOUND, + IO_WQ_UNBOUND, +}; + /* deprecated, see struct io_uring_rsrc_update */ struct io_uring_files_update { __u32 offset; -- 2.1.4