From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0051.outbound.protection.outlook.com [104.47.38.51]) by dpdk.org (Postfix) with ESMTP id F05C56C99 for ; Tue, 6 Sep 2016 13:26:04 +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=rCORQ7bYNwoE2mW5qkNzn/J6tM6rG/wJSONSazXtjU76ApTv01lyMtjU+S/50ot5E8JHT/XkqGbKUNzYM1HxmlWlESNiDoNz4Bvn7+lHG2PVhG86B9XvYCS+RQ4VSV9lfZt+NpmruR4Qk+MwrhlK5BHv3x7JPHD1vp4q7MTOlF8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vladyslav.Buslov@harmonicinc.com; Received: from kms.harmonicinc.com (95.67.66.62) 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; Tue, 6 Sep 2016 11:26:02 +0000 From: Vladyslav Buslov To: CC: Date: Tue, 6 Sep 2016 14:25:13 +0300 Message-ID: <20160906112513.26090-2-vladyslav.buslov@harmonicinc.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160906112513.26090-1-vladyslav.buslov@harmonicinc.com> References: <20160906112513.26090-1-vladyslav.buslov@harmonicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.67.66.62] X-ClientProxiedBy: AM4PR02CA0027.eurprd02.prod.outlook.com (10.165.239.165) To MWHPR11MB1360.namprd11.prod.outlook.com (10.169.235.22) X-MS-Office365-Filtering-Correlation-Id: a2bfcf05-3d44-451e-017e-08d3d6489653 X-Microsoft-Exchange-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DTQGQOozsssgUAfU5eeuLwz3xtyQLAXRvkGM5WM1ao=; 20:xsNDv8p5ZmULbyRPlAwXkpDOoCggUYbnzHR8pgY6l9jb1JHz6hT4162FXkZFd8hCQ4RQwmKBAAW+XQmxRxABCko0++ueA9Ga7T47oI0rCDlG8tFf/D2oLmJO7QvwibZXaOVjYllwODia4h2TqoS7FQ1qNRxIUJIReoXqVxf+jTJl2pSpIPHogGF544djVsS4RI8eEzXRXJjZmGJ8suhL5O3x6uFCvj7vEkPvtI9cLW5yI7qzieLM7DN/SkLG4669TCcZyC0i/DjE+xjEi461VG/RgKf47qWQJKugCNyeNhpd38BX8yyiJZ6pBW2rjCgM1WvWoRLkt/7VAL46p/mMRzCyaZ9MN2hJ3jvfHDCI+Se0ipNuifMQxEXtNiBDAN/niglv40pv8HTKu3ZdNG20KKHpdoe0ZRcDayKaQ/nTLZzyzeuLTzKbopUGnWSoqADWH3ip06eoK7+Awaor0OJRmqHcYRXX+CeBpi4fe+66E82e1dPbytreECYmfIA5YAOL 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)(10201501046)(3002001)(6055026); SRVR:MWHPR11MB1360; BCL:0; PCL:0; RULEID:; SRVR:MWHPR11MB1360; X-Microsoft-Exchange-Diagnostics: 1; MWHPR11MB1360; 4:QsGU5d0RvQcHgw+2/TPe6oBhTGq7PVPivQOm/3LTc1HPTusb1cRLkm/jdctBNcl63OPewKs3J9wLY7/PpuaYymVaNvb3K1ro6ex94dd0v95SPRS4LvQz1QtO5F0F42U9oRhhMLxXRCZunjlrnW4kmM9L9m5sdbIZcLR/Bl06K4Io50KL7sEg4IU8gZn5jA6QP+gXTbHHG6X7s716hmw2Yvq0o9aAMznwiJVClD9I0VGIqOfoCF6g6f20TSj3kxqzuS5uAX3d/4pVG8jXdvRcdrqo4/Dh+VFNofzvRhqgTQ52WDOLsbnxzpCXSJSJxieE51KEguqPHKpOexKkUbU2oRY8+6vxZwH7erYFtFaIwHMvOV0PFbK6Kiop6zgZysThasB9T31tKojZGIlabsM2PBvTJAkh7xcCy+k3c1IJKC2ea+n0CQGZKAjyL6TU9mVY X-Forefront-PRVS: 0057EE387C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(2351001)(5660300001)(92566002)(81166006)(50226002)(81156014)(2906002)(1076002)(68736007)(106356001)(7736002)(53416004)(7846002)(42186005)(101416001)(110136002)(19580395003)(586003)(305945005)(189998001)(105586002)(97736004)(229853001)(47776003)(2950100001)(48376002)(5003940100001)(4326007)(66066001)(76176999)(19580405001)(3846002)(69596002)(8676002)(86362001)(33646002)(77096005)(50466002)(36756003)(6116002)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB1360; H:kms.harmonicinc.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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:+kZuhuE7WbdzjoLF7SR4KG9X+RAO8Jv1V3CmpmZLZ?= =?us-ascii?Q?k/zmWs6pYJLasWU5sR4J135CqTG63RNTccWOTIPUte43KozFtok8S9Vb2YPz?= =?us-ascii?Q?esct9YEKvVDwd6YA3U4LFkfbVVLmP5Z6vClK04cvC+v32VZ4GQuagU+8GwWU?= =?us-ascii?Q?mebAyljN8XwgnzgYo4+PTcOE76Je9Ie/bly1IGDhCNoQ3AlILS54VF6ujGaX?= =?us-ascii?Q?K8BdikqZSUt5YxxUuIID95LBmEWDvQG5NR2Dd4+YrXu01ccWX8vUKoZXzlAB?= =?us-ascii?Q?QKlvEPQ7pYfi7XF0v4ox3p7SShphyrjkIxEEfNuJgxA5cXH3uH9k9pGDUdIO?= =?us-ascii?Q?Qfxx372TH5ohIc1Ti5eEe1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Iapd2YCBUisXOmEvdft4jSyTr6io18bfeYff06ezfTnwfjauVF/dnocxyOrhp9fd5xfWSiIfQRiMFtxxpgONgsbf841kh9YKBDfiZSfa9OV8qbv2VL7aRgtAW0LLeINFLYGyf5xUEXSdSZwWgcybmaXoEk7WAnmOF0duncAYblQHp4ATp6y6/JP1YARLIIWvK8RuqhHGV9iFQmwUGQwDeBGBp5fUXuCOyLJtzO9WVsuFav3BSDo0W5oYtdN29QrwvU8x1ih+xQdUtb9PDJwqQVkq/kkZ6P7bsOZKQo9xaODkd+APg==; 5:gNzUmejtw7mqv3aYIRFbdWlYT9N73J8vzAe+vO2K4gs6KRQsF1VNsMaJ/sBuWc8yMiYnrUUZR4doUOnxXyyYGYZK4xPU0j5Iu8shcqDKC5V+1Vu1lD3UYpCEDg+I93fA4WfhCcxwqW1vslpLSvT45A==; 24:QEH/WOTgZhPdbX0KulzxtZbGlS9krFXBICkBKZUrWcCvrYIUktj1T+WyiDeY60wjcT83JUYcremG3jvm6/E73Kd50LPji+mCjMhEXm+513Y=; 7:0M8lI2N+zsKICz9P/6ink3t2J42lAIuWXhNv7gz9F/PqyPY6gXr1lRZ9phowjNeMYr+yy1b7VF2v/O/qDXBbCw+G5Luooy9KoBeWcq5ttfZYrJTYnGe3SXirN/Ved97DzV2bgE0fO3i3e62UmV7lBdvLQgbcBxkKpqq8HKRb9zBDEzFI7ez/LhyIZ8TLx5pI1zynggkxKEOvtWGbOgdUURTBUXqhyaVGhQX/SnpigKzHMjk2PGkip/eY25+UgAli SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR11MB1360; 20:tzRNpt5mirz0+n7b4Hnhvr3bujyQKBBeg7oLm3dE/Onh5SP0zGghSbQsXUb9XkS+1tqUuf2cqEbTVJaalxHIl1MbHu25rBoVOyMnftHtVE9ows3G/ZOfa9ogBY50l5y6XCG841yApNZDrmfZx1WvT4XA94GE073s4lWUKab052c= X-OriginatorOrg: harmonicinc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2016 11:26:02.9797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1360 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: Tue, 06 Sep 2016 11:26:05 -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