From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbbIHIgk (ORCPT ); Tue, 8 Sep 2015 04:36:40 -0400 Received: from mail-am1on0054.outbound.protection.outlook.com ([157.56.112.54]:13258 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753931AbbIHIge (ORCPT ); Tue, 8 Sep 2015 04:36:34 -0400 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=mellanox.com; Subject: Re: [PATCH 5/7] devcg: device cgroup's extension for RDMA resource. To: Parav Pandit , , , , , , , , References: <1441658303-18081-1-git-send-email-pandit.parav@gmail.com> <1441658303-18081-6-git-send-email-pandit.parav@gmail.com> CC: , , , , , , , From: Haggai Eran Message-ID: <55EE9DF5.7030401@mellanox.com> Date: Tue, 8 Sep 2015 11:36:05 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441658303-18081-6-git-send-email-pandit.parav@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.0.52.254] X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD009;1:uj2MQT7AZxTHETbs+K2yJv1aIPsMD9NHHQfudfb42o6LYow2iLKmpRohFlxKuojeXEDlDg1uWiRKFsMWqXtYkkY9HT5e+Tx27oL4PDUiQXh/JEeUnDoUXJ483clqXfV6nvo81HKSbIJ++mriTV1wpsW/J1Cn22MA+cpq/a9pwyd59qI0re5uLE+HrS2wcazYbF/urRX08LOD7Ee1BZeln7hviTcOqZzHcKCZxc4s11MXJ3PjRuSXpDJE5vDlSJ3HBDMR3PgQCFUZwpOP65lwGMtJuunV1lr+JXZCbBPvguqjRAB737AO5nvHOB9G5sV9y9UtC76i98zCOmDTE5P6g4bPnAoDNGPlh51pmcMMp2ecwnXmxKW7vktUMV4/z3Arv1Jyohh1nmaUcT0rS0eOZDJ2Fx8s3XHictGUKP7t7nc= X-Forefront-Antispam-Report: CIP:193.47.165.134;CTRY:IL;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(479174004)(24454002)(62966003)(77156002)(6806004)(83506001)(65956001)(23746002)(2950100001)(189998001)(54356999)(50466002)(65816999)(64706001)(86362001)(97736004)(5001770100001)(68736005)(87936001)(33656002)(47776003)(5001830100001)(65806001)(46102003)(87266999)(4001350100001)(50986999)(76176999)(77096005)(64126003)(5001860100001)(4001540100001)(106466001)(59896002)(5004730100002)(92566002)(2201001)(36756003)(80316001)(5007970100001)(3940600001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR05MB1457;H:mtlcas13.mtl.com;FPR:;SPF:Pass;PTR:ErrorRetry;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB1457;2:GCSrM75ZpgiIgvnAWFQOOAv4caZse9P5B/L7pvXZnfP9npeGR0LEWztVEnJRT8wWJK+Z5WM/8R/7Op8P9VWIeT1FnYKpVdy8RRlGSORzha4p0XNGrF3ZYSQiPkmcgPyHObtVm3XMiP1a+goUWvUx7r09QF6L3g3e5xp1tkGGs74=;3:KuQfqoj01LyDOZYkOzvbTyZFbjmooSRZrOX088p6W46Ks7lTS7/utUwoZri7Z0f4Oc5zvWWo7HhLQpnvC5WPSlhejvm7ktOlNX7rZYiXer1GLEzMBM8UE6MlqUTJzhgGSpdlacI1sx0jcJb6HeBF3XaLZT03K0AVLjYYFY1SS6RESKWHF4MYUwslRojsVxDKqSUELrMpPyj9hE2DVapC0iRCOfiJ5i4JO9qjJv9YIopMqQc51xpGG8dflZqmwu0rmLnRMFbTBjU/VxdoSSKaIQ==;25:l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VKjB6q4rsrJ6dMcWC7FrwTPPRG180EhM+EJGyUJabNDAczsbvxLtv4sFNXsBjroC43JnwPp9X4BXi2ic4i80aZLKY1a8WGbEJS4ANbg7J6pUh0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:AM4PR05MB1457;BCL:0;PCL:0;RULEID:;SRVR:AM4PR05MB1457; X-Forefront-PRVS: 069373DFB6 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;AM4PR05MB1457;23:LTJJjLJaamqXvgM22h8/ygvRiRHtP78GRAadR?= =?Windows-1252?Q?e1qWH1BUChMHvoS5vd4gHRSLgdzNP78cPltYCC3AEeZ0M4wBqp58zIea?= =?Windows-1252?Q?ACGrxMjj7aZBkvIzGFJWkCviggFKX5LbFXBTXrb3YStjxSmC3dUdGmKC?= =?Windows-1252?Q?sCJO8fY+G3CUbjaIzY2ny5UfrMBfP9MNQnU7rmojLKFw6HImn4D0aGn/?= =?Windows-1252?Q?0byyHIl+AErxgfIsl7Swu5bHK26BMVA/J+EMS+lpOiyB49OfbCFn7/iW?= =?Windows-1252?Q?j/izidMivRRTytLJu1ibTO37d6j+VPm4+QciWhF8q+xRoDG5mwK3i/W3?= =?Windows-1252?Q?tUhQB8ACs3D54hTeLDwnSPo4tHQQccIXaa/rZHRUPvee59tcvcNRxzEl?= =?Windows-1252?Q?1G2/c7UCplYoXZPJrKkXGV+s+pYpMZULd11n1ZHOiuDVEJubDCxcPeEl?= =?Windows-1252?Q?k1hj4svCavlkqGUaCHmjBoa+dGtVVygN4huK5W1yuNvSBcKWslkb3cnD?= =?Windows-1252?Q?KodPnttQLQp7GKdLfvy9J13gHgSO58DArBfGqxr8RG6XcJiY7txXK4dI?= =?Windows-1252?Q?sepBOfS7s188XfrGSbyEnEzMePVQqZK9CG661wZnB2dlrtTJsZPmbfbX?= =?Windows-1252?Q?qWHHv6j6wjFCa6DLtlnDYgN4/NSclwuNW0auq7kugarh1dwmIE6/ZkNU?= =?Windows-1252?Q?zUf92LzngDFEenoELSpV96opjIJN5iUG9c0bCU6HOFxt7Nbb/RvpQr7C?= =?Windows-1252?Q?AgIEB1rc45aPdn9gyKdW+QVbzmxqdIqTZ2L/patumtQ6flSdKLR0e4xh?= =?Windows-1252?Q?gFQrR8SDGzQ0lVWddGRqVyZAFqr7Az45GqEACN40mQDOPOhWxDx+8pjH?= =?Windows-1252?Q?bbN0MaDkm9YMIDEP23vsYMJxE/HRhEA1UrQJJFEw7ISiJrjDrUfz7ZpV?= =?Windows-1252?Q?0E+IVLS1LgD0VjqqouK3M2hNS49qirHgzou1tDLxdeCoOmKnyY10HGaO?= =?Windows-1252?Q?mO4EJcqmiTxfAAbaxFPjXiVFKi0k+xxYs+4T/aCNl/3dV9S9175nKkJ1?= =?Windows-1252?Q?3vCRxf4v4aCrvT6wblOopAomiQhZfIooOw8nwXCdW9H88nhpzhfNXpin?= =?Windows-1252?Q?FLMzbN3/48a6iNy6AoSMmoTn3YdzsYidO6Dn8KWZv84FB0J26iy74H91?= =?Windows-1252?Q?yIu5F66G1jZpjFvgRZVobxcfPbtPjPACBoCEB3Dg2wie5mCxUxXpB8pb?= =?Windows-1252?Q?Pv7YXe9Umj5VBPv06MhRs3Gbvm0iJJ4dltfGzh78Vjt2LrFrO9S/hdKk?= =?Windows-1252?Q?y2XAJD2KBzfCnao/ZmakLXzRQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB1457;5:z/Ln05Dty0Ey87sHgbjK9Hn+Tg52vjYlVtFYEXlmHrw0G2W1Ybx5mcUKI6yFXV63uhbqj7mMdzXnrcyZnrePtReQ9csY1Othi0PHR/ouSaYHZJ5FY5a/XsVYLQQeLENIPHNQ2Pu5vtodSoKG2O1q/A==;24:1WKmgPsAc7VBG5bZSaZCFuP0uuuBSzs4f3OYUiMWPOdbuU47fpYhKeiBdA2XsocIIaPTEU84OF5jZAvUkl7lnsyWHXCiO/owLhX+jrpM9uU=;20:I9k1AmfeB7+l+v6YGfKTreySBXHTWT9pcxBNcjqWFDnA/QuNwyN2VJe32AhN3Jx9ACbEzNsGB3zfLarmgB+rcg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2015 08:36:27.7940 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[193.47.165.134];Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1457 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/09/2015 23:38, Parav Pandit wrote: > +void devcgroup_rdma_uncharge_resource(struct ib_ucontext *ucontext, > + enum devcgroup_rdma_rt type, int num) > +{ > + struct dev_cgroup *dev_cg, *p; > + struct task_struct *ctx_task; > + > + if (!num) > + return; > + > + /* get cgroup of ib_ucontext it belong to, to uncharge > + * so that when its called from any worker tasks or any > + * other tasks to which this resource doesn't belong to, > + * it can be uncharged correctly. > + */ > + if (ucontext) > + ctx_task = get_pid_task(ucontext->tgid, PIDTYPE_PID); > + else > + ctx_task = current; So what happens if a process creates a ucontext, forks, and then the child creates and destroys a CQ? If I understand correctly, created resources are always charged to the current process (the child), but when it is destroyed the owner of the ucontext (the parent) will be uncharged. Since ucontexts are not meant to be used by multiple processes, I think it would be okay to always charge the owner process (the one that created the ucontext). > + dev_cg = task_devcgroup(ctx_task); > + > + spin_lock(&ctx_task->rdma_res_counter->lock); > + ctx_task->rdma_res_counter->usage[type] -= num; > + > + for (p = dev_cg; p; p = parent_devcgroup(p)) > + uncharge_resource(p, type, num); > + > + spin_unlock(&ctx_task->rdma_res_counter->lock); > + > + if (type == DEVCG_RDMA_RES_TYPE_UCTX) > + rdma_free_res_counter(ctx_task); > +} > +EXPORT_SYMBOL(devcgroup_rdma_uncharge_resource); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haggai Eran Subject: Re: [PATCH 5/7] devcg: device cgroup's extension for RDMA resource. Date: Tue, 8 Sep 2015 11:36:05 +0300 Message-ID: <55EE9DF5.7030401@mellanox.com> References: <1441658303-18081-1-git-send-email-pandit.parav@gmail.com> <1441658303-18081-6-git-send-email-pandit.parav@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1441658303-18081-6-git-send-email-pandit.parav@gmail.com> Sender: linux-doc-owner@vger.kernel.org To: Parav Pandit , 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 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 List-Id: linux-rdma@vger.kernel.org On 07/09/2015 23:38, Parav Pandit wrote: > +void devcgroup_rdma_uncharge_resource(struct ib_ucontext *ucontext, > + enum devcgroup_rdma_rt type, int num) > +{ > + struct dev_cgroup *dev_cg, *p; > + struct task_struct *ctx_task; > + > + if (!num) > + return; > + > + /* get cgroup of ib_ucontext it belong to, to uncharge > + * so that when its called from any worker tasks or any > + * other tasks to which this resource doesn't belong to, > + * it can be uncharged correctly. > + */ > + if (ucontext) > + ctx_task = get_pid_task(ucontext->tgid, PIDTYPE_PID); > + else > + ctx_task = current; So what happens if a process creates a ucontext, forks, and then the child creates and destroys a CQ? If I understand correctly, created resources are always charged to the current process (the child), but when it is destroyed the owner of the ucontext (the parent) will be uncharged. Since ucontexts are not meant to be used by multiple processes, I think it would be okay to always charge the owner process (the one that created the ucontext). > + dev_cg = task_devcgroup(ctx_task); > + > + spin_lock(&ctx_task->rdma_res_counter->lock); > + ctx_task->rdma_res_counter->usage[type] -= num; > + > + for (p = dev_cg; p; p = parent_devcgroup(p)) > + uncharge_resource(p, type, num); > + > + spin_unlock(&ctx_task->rdma_res_counter->lock); > + > + if (type == DEVCG_RDMA_RES_TYPE_UCTX) > + rdma_free_res_counter(ctx_task); > +} > +EXPORT_SYMBOL(devcgroup_rdma_uncharge_resource);