From patchwork Tue Jan 5 18:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 7958521 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 89EC59F9A0 for ; Tue, 5 Jan 2016 19:02:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC039200DF for ; Tue, 5 Jan 2016 19:02:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4C2220218 for ; Tue, 5 Jan 2016 19:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752604AbcAETAe (ORCPT ); Tue, 5 Jan 2016 14:00:34 -0500 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34024 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbcAETA1 (ORCPT ); Tue, 5 Jan 2016 14:00:27 -0500 Received: by mail-pa0-f68.google.com with SMTP id yy13so16981283pab.1; Tue, 05 Jan 2016 11:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m2LIUNxpvnKpZOl9WtjPkWC2b92uDaa25hbxYLYMeL4=; b=gKVdJAwUMrx7Ud4cm6TuZn8TYMfTphE5g70k7+yxhBio/sKJ1F09kJC8IPVApr38Rk GNTt/v5us5Jve6mc1N8+zjVrVSq5TpgjSeUUVa+GipJ9Q1ZnRu+QGMKugVNHicZlz2YU GYdPKPeumk2MMLT1l7dra+benmDntcmNlzP4YKMLaVZdImhfAWu5L8wHRB2ObmPw7uRM uYk6T55p9cl/smGFAXGu/IBExbSylPlGsiKP3Q9m7sgAEAx8PYtmHOHRjtMDo8z30TVs Ont6AtEjJ0tfpZVchRvwSZVupird37A2H06wChsiCZ6fFPcHOscpmHV3350hJwxPbJdc kflQ== X-Received: by 10.67.3.196 with SMTP id by4mr134980726pad.67.1452020426341; Tue, 05 Jan 2016 11:00:26 -0800 (PST) Received: from server1.localdomain ([106.216.177.49]) by smtp.gmail.com with ESMTPSA id q27sm86218546pfi.83.2016.01.05.11.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2016 11:00:24 -0800 (PST) From: Parav Pandit To: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, tj@kernel.org, lizefan@huawei.com, hannes@cmpxchg.org, dledford@redhat.com, liranl@mellanox.com, sean.hefty@intel.com, jgunthorpe@obsidianresearch.com, haggaie@mellanox.com Cc: corbet@lwn.net, james.l.morris@oracle.com, serge@hallyn.com, ogerlitz@mellanox.com, matanb@mellanox.com, raindel@mellanox.com, akpm@linux-foundation.org, linux-security-module@vger.kernel.org, pandit.parav@gmail.com Subject: [PATCHv1 1/6] rdmacg: Added rdma cgroup header file Date: Wed, 6 Jan 2016 00:28:01 +0530 Message-Id: <1452020286-9508-2-git-send-email-pandit.parav@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1452020286-9508-1-git-send-email-pandit.parav@gmail.com> References: <1452020286-9508-1-git-send-email-pandit.parav@gmail.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added rdma cgroup header file which defines its APIs to perform charing/uncharing functionality. Signed-off-by: Parav Pandit --- include/linux/cgroup_rdma.h | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 include/linux/cgroup_rdma.h diff --git a/include/linux/cgroup_rdma.h b/include/linux/cgroup_rdma.h new file mode 100644 index 0000000..01d220f --- /dev/null +++ b/include/linux/cgroup_rdma.h @@ -0,0 +1,91 @@ +#ifndef _CGROUP_RDMA_H +#define _CGROUP_RDMA_H + +/* + * This file is subject to the terms and conditions of version 2 of the GNU + * General Public License. See the file COPYING in the main directory of the + * Linux distribution for more details. + */ + +enum rdmacg_resource_pool_type { + RDMACG_RESOURCE_POOL_VERB, + RDMACG_RESOURCE_POOL_HW, + RDMACG_RESOURCE_POOL_TYPE_MAX, +}; + +struct ib_device; +struct pid; +struct match_token; + +#ifdef CONFIG_CGROUP_RDMA +#define RDMACG_MAX_RESOURCE_INDEX (64) + +struct rdmacg_pool_info { + struct match_token *resource_table; + int resource_count; +}; + +struct rdmacg_resource_pool_ops { + struct rdmacg_pool_info* + (*get_resource_pool_tokens)(struct ib_device *); +}; + +/* APIs for RDMA/IB subsystem to publish when a device wants to + * participate in resource accounting + */ +void rdmacg_register_ib_device(struct ib_device *device); +void rdmacg_unregister_ib_device(struct ib_device *device); + +/* APIs for RDMA/IB subsystem to charge/uncharge pool specific resources */ +int rdmacg_try_charge_resource(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int resource_index, + int num); +void rdmacg_uncharge_resource(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int resource_index, + int num); + +void rdmacg_set_rpool_ops(struct ib_device *device, + enum rdmacg_resource_pool_type pool_type, + struct rdmacg_resource_pool_ops *ops); +void rdmacg_clear_rpool_ops(struct ib_device *device, + enum rdmacg_resource_pool_type pool_type); +int rdmacg_query_resource_limit(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int *limits, int max_count); +#else +/* APIs for RDMA/IB subsystem to charge/uncharge device specific resources */ +static inline +int rdmacg_try_charge_resource(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int resource_index, + int num) +{ return 0; } + +static inline void rdmacg_uncharge_resource(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int resource_index, + int num) +{ } + +static inline +int rdmacg_query_resource_limit(struct ib_device *device, + struct pid *pid, + enum rdmacg_resource_pool_type type, + int *limits, int max_count) +{ + int i; + + for (i = 0; i < max_count; i++) + limits[i] = S32_MAX; + + return 0; +} +#endif /* CONFIG_CGROUP_RDMA */ +#endif /* _CGROUP_RDMA_H */