From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0082.outbound.protection.outlook.com [104.47.37.82]) by dpdk.org (Postfix) with ESMTP id C81712BAC for ; Sat, 10 Sep 2016 15:50:47 +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=OpwXX0CM5TOvAFImHzC7CIRcsgXZKxePG9fG7xD1PB+PM3wEe3N4yDRn3Os+5PuT3Rca3bu3UacmY+d9n0siAs4bmP7c+iERBCTGR1TOJqDM8YwRBqJpQ2EFzagrM1yceDH+I8NQHLBTg8H4IdBAqGRLu5H6MJAz3xpT6Wv3slw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vladyslav.Buslov@harmonicinc.com; Received: from kms.harmonicinc.com (62.205.135.152) by MWHPR11MB1360.namprd11.prod.outlook.com (10.169.235.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Sat, 10 Sep 2016 13:50:44 +0000 From: Vladyslav Buslov To: Date: Sat, 10 Sep 2016 16:50:15 +0300 Message-ID: <20160910135016.6468-1-vladyslav.buslov@harmonicinc.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160906112513.26090-2-vladyslav.buslov@harmonicinc.com> References: <20160906112513.26090-2-vladyslav.buslov@harmonicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [62.205.135.152] X-ClientProxiedBy: AM4PR01CA0056.eurprd01.prod.exchangelabs.com (10.164.74.24) To MWHPR11MB1360.namprd11.prod.outlook.com (10.169.235.22) X-MS-Office365-Filtering-Correlation-Id: 928f9b9e-eb86-4efd-65bb-08d3d98176c1 X-Microsoft-Exchange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nraLU+TjrAfuQ3fH4Uwz9NGuEPlMR8aOZp7syv0l2n1cApydKdWptRH9HKaDtZ3NE40sglQfq0YZLdgo4yvtVDZna+tGa+v20Lfcw+lAis13wstQPSKuYkYsiG3lgIweagiNvZkXuyfJsb6F6aZHVvun7Zp2js7Ock39zLkp+tfDE/JzuC0WwjsTkgyZ8dRY7K2SEGEZGFQB62dJzuPrhuMigF0T6OU1X1h32OAdZWz4LL2podOOZz/ggb7s 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:MWHPR11MB1360; BCL:0; PCL:0; RULEID:; SRVR:MWHPR11MB1360; X-Forefront-PRVS: 0061C35778 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(47776003)(42186005)(92566002)(81166006)(7736002)(97736004)(586003)(2906002)(1076002)(81156014)(50226002)(105586002)(68736007)(2351001)(7846002)(107886002)(106356001)(189998001)(53416004)(305945005)(19580395003)(5660300001)(101416001)(2950100001)(36756003)(48376002)(5003940100001)(50466002)(110136002)(66066001)(76176999)(6116002)(8676002)(50986999)(3846002)(86362001)(69596002)(19580405001)(77096005)(33646002)(450100001)(229853001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB1360; 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; MWHPR11MB1360; 23:qXS2C+NTEp71Pwr0cGdNQmEAXP8NP/jpbn4OQhB1U?= =?us-ascii?Q?uvSRtPRQ5+D8C49VKm82uC8w5T5icidmR+zyy6U9jcJDuUsAgNHPqosx9gSF?= =?us-ascii?Q?NXc/m2vixjUG2L1K5Glgb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xZzE4dPVJ4h1EN+FyBfryxzOsxNcFudlB3+wDaxvbm6e9XwOmx6HsNJ9xAeUEhBIJUeNMAyZHd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR11MB1360; 20:becrSz17uk7pasT5wQMmR9bVpzye8RGTuiRIjn04YfcgUBKJ5og4H40JFQO93rsW/5DTWSRqWyXviCNjhQi81sK2g0jxFIz6YUNo+XSHOvDYKpnKwL7CNGQU9zWTyPDz2eWD6B37kTH6twOssSskVQ0va0jPPCM2zbE56TZE6F0= X-OriginatorOrg: harmonicinc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2016 13:50:44.9781 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1360 Subject: [dpdk-dev] [PATCH v2 1/2] 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: Sat, 10 Sep 2016 13:50:48 -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