From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0070.outbound.protection.outlook.com [104.47.40.70]) by dpdk.org (Postfix) with ESMTP id C6B6537B4 for ; Fri, 2 Sep 2016 17:14:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harmonic.onmicrosoft.com; s=selector1-harmonicinc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ahphTBNAKQWiu+tYrV8lXzF/ZNFR6Gir5BVHigNgWiA=; b=Fkx+3QhyfICePEI3i8MrYnsGMYfXXWJ47IWoa2qFyKbLCvg23KgwbWuf2DPMqr+g7NAc5MAR1NsAjPhea1f3dN5Od0yte25F5CzB4av920HgOg3Y5dXW+P6mRbhhMHy8IcLT2tTwG6DUmsse0MwTxZm9Nx24ZdXjpcnyN3pMKcM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vladyslav.Buslov@harmonicinc.com; Received: from kms.harmonicinc.com (62.205.135.152) by DM5PR11MB1355.namprd11.prod.outlook.com (10.168.108.147) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Fri, 2 Sep 2016 15:14:03 +0000 From: Vladyslav Buslov To: Date: Fri, 2 Sep 2016 18:13:33 +0300 Message-ID: <20160902151333.11901-1-vladyslav.buslov@harmonicinc.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <57BF04D6.9040108@intel.com> References: <57BF04D6.9040108@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [62.205.135.152] X-ClientProxiedBy: VI1PR10CA0083.EURPRD10.PROD.OUTLOOK.COM (10.166.136.179) To DM5PR11MB1355.namprd11.prod.outlook.com (10.168.108.147) X-MS-Office365-Filtering-Correlation-Id: cec79e42-bb56-482c-0249-08d3d343c6d7 X-Microsoft-Exchange-Diagnostics: 1; DM5PR11MB1355; 2:TB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nGA5AGkr+05rheO2CCQzXxLXay2/wG6bhCJX1AfpVqoi5HV5UXTpwvWpRC31YreSzTk8QnzCBsm8nvqL0tCeIn9EtzOc+chhiS5WuqfDiR8VtPuobl23ObJDiWxLVPFtMrAoMo76oRLjUl4VrCzSvFxqD/8/9/FXlGGnkgdaZ2/bRH3lWuZ+EDJXXUKT5r4Aq9tuGNIyZyNPcDyYa4qDhm9p X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:DM5PR11MB1355; BCL:0; PCL:0; RULEID:; SRVR:DM5PR11MB1355; X-Forefront-PRVS: 00531FAC2C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(7846002)(1076002)(106356001)(305945005)(229853001)(81166006)(101416001)(110136002)(7736002)(19580405001)(19580395003)(77096005)(5003940100001)(50226002)(81156014)(92566002)(97736004)(2950100001)(50986999)(586003)(68736007)(8676002)(33646002)(2906002)(42186005)(50466002)(107886002)(189998001)(66066001)(69596002)(450100001)(105586002)(53416004)(2351001)(6116002)(47776003)(76176999)(5660300001)(3846002)(86362001)(48376002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR11MB1355; H:kms.harmonicinc.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: harmonicinc.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR11MB1355; 23:q3XbS7qZYXk90ukP+xAAiUBW/+BwZdlXfxW4WKgBY?= =?us-ascii?Q?/XYWynIGmuRtGieuXXXZJR3is1qwKPojIddMG99HE7+8p/exOzHVFfokN+yJ?= =?us-ascii?Q?qaWdc+5hkWj2QLecSRJLb0diM9Mcae6s9H2r1hsGCwPmtXpxknwr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SQBFDVOMzIQWk+qDMLUvMGd0tXj4voz7STRT/RDkp9JQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR11MB1355; 20:svHP3uKDQ82IYbxMXqweO3SxaKzqySHmARtTAUv16N/xBb/Ng2OIKjOfw7q+XXmR3mAbA9BFt7wwxGh95xRKqY8TffnO93c19T1j86hCO/ZNVNIVksap7Ljz/qi9ncFByUoFm3up0/U6vcnQcSxQV1KdDUWbp68XtUq1Oh3z94g= X-OriginatorOrg: harmonicinc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2016 15:14:03.6586 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1355 Subject: [dpdk-dev] [PATCH] kni: add support for core_id param in single threaded mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2016 15:14:06 -0000 Allow binding KNI thread to specific core in single threaded mode by setting core_id and force_bind config parameters. Signed-off-by: Vladyslav Buslov --- lib/librte_eal/linuxapp/kni/kni_misc.c | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 59d15ca..5e7cf21 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,7 @@ static int kni_net_id; struct kni_net { unsigned long device_in_use; /* device in use flag */ + struct mutex kni_kthread_lock; struct task_struct *kni_kthread; struct rw_semaphore kni_list_lock; struct list_head kni_list_head; @@ -123,6 +125,9 @@ static int __net_init kni_init_net(struct net *net) /* Clear the bit of device in use */ clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); + mutex_init(&knet->kni_kthread_lock); + knet->kni_kthread = NULL; + init_rwsem(&knet->kni_list_lock); INIT_LIST_HEAD(&knet->kni_list_head); @@ -139,9 +144,9 @@ static int __net_init kni_init_net(struct net *net) static void __net_exit kni_exit_net(struct net *net) { -#ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS struct kni_net *knet = net_generic(net, kni_net_id); - + mutex_destroy(&knet->kni_kthread_lock); +#ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS kfree(knet); #endif } @@ -236,16 +241,9 @@ kni_open(struct inode *inode, struct file *file) return -EBUSY; /* Create kernel thread for single mode */ - if (multiple_kthread_on == 0) { + if (multiple_kthread_on == 0) KNI_PRINT("Single kernel thread for all KNI devices\n"); - /* Create kernel thread for RX */ - knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet, - "kni_single"); - if (IS_ERR(knet->kni_kthread)) { - KNI_ERR("Unable to create kernel threaed\n"); - return PTR_ERR(knet->kni_kthread); - } - } else + else KNI_PRINT("Multiple kernel thread mode enabled\n"); file->private_data = get_net(net); @@ -263,9 +261,13 @@ kni_release(struct inode *inode, struct file *file) /* Stop kernel thread for single mode */ if (multiple_kthread_on == 0) { + mutex_lock(&knet->kni_kthread_lock); /* Stop kernel thread */ - kthread_stop(knet->kni_kthread); - knet->kni_kthread = NULL; + if (knet->kni_kthread != NULL) { + kthread_stop(knet->kni_kthread); + knet->kni_kthread = NULL; + } + mutex_unlock(&knet->kni_kthread_lock); } down_write(&knet->kni_list_lock); @@ -415,10 +417,9 @@ kni_ioctl_create(struct net *net, } /** - * Check if the cpu core id is valid for binding, - * for multiple kernel thread mode. + * Check if the cpu core id is valid for binding. */ - if (multiple_kthread_on && dev_info.force_bind && + if (dev_info.force_bind && !cpu_online(dev_info.core_id)) { KNI_ERR("cpu %u is not online\n", dev_info.core_id); return -EINVAL; @@ -581,6 +582,21 @@ kni_ioctl_create(struct net *net, if (dev_info.force_bind) kthread_bind(kni->pthread, kni->core_id); wake_up_process(kni->pthread); + } else { + mutex_lock(&knet->kni_kthread_lock); + if (knet->kni_kthread == NULL) { + knet->kni_kthread = kthread_create(kni_thread_single, + (void *)knet, + "kni_single"); + if (IS_ERR(knet->kni_kthread)) { + kni_dev_remove(kni); + return -ECANCELED; + } + if (dev_info.force_bind) + kthread_bind(knet->kni_kthread, kni->core_id); + wake_up_process(knet->kni_kthread); + } + mutex_unlock(&knet->kni_kthread_lock); } down_write(&knet->kni_list_lock); -- 2.8.3