changes for thread-core pinning

This commit is contained in:
Raymond Knopp
2022-06-11 08:08:03 +02:00
parent 7b8f776246
commit 6236fe8e77
8 changed files with 57 additions and 21 deletions
@@ -43,6 +43,7 @@
#include <unistd.h>
#include <errno.h>
#include "common/utils/LOG/vcd_signal_dumper.h"
#include <sched.h>
#include "common_lib.h"
#include "ethernet_lib.h"
@@ -148,11 +149,11 @@ int eth_socket_init_udp(openair0_device *device) {
printf("ETHERNET: Cannot set SO_NO_CHECK option on socket (user %d)",i);
exit(0);
}
#if 0 /*def SO_ATTACH_REUSEPORT_EBPF*/
if (setsockopt(eth->sockfdd[i], SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int))) {
printf("ETHERNET: Cannot set SO_REUSEPORT option on socket (user %d)",i);
exit(0);
}
#ifdef SO_ATTACH_REUSEPORT_EBPF*/
struct sock_filter code[]={
{ BPF_LD | BPF_W | BPF_ABS, 0, 0, SKF_AD_OFF + SKF_AD_CPU }, // A = #cpu
{ BPF_RET | BPF_A, 0, 0, 0 }, // return A
@@ -451,8 +452,8 @@ void *udp_read_thread(void *arg) {
// zero-copy and corrected the header component.
memcpy((void*)(device->openair0_cfg->rxbase[aid]+offset),
(void*)&buffer[APP_HEADER_SIZE_BYTES],
count-APP_HEADER_SIZE_BYTES);
LOG_D(PHY,"thread_id %d, aid %d, TS %llu, TS0 %llu, offset %d\n",u->thread_id,aid,(unsigned long long)TS,fhstate->TS0,offset);
count-APP_HEADER_SIZE_BYTES);
LOG_D(PHY,"thread_id %d (%d), aid %d, TS %llu, TS0 %llu, offset %d\n",u->thread_id,sched_getcpu(),aid,(unsigned long long)TS,fhstate->TS0,offset);
}
sleep(1);
}
@@ -473,7 +474,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, uin
// poll/sleep until we accumulated enough samples on each antenna port
int count=0;
while (fhstate->first_read == 1 && min_TS < (fhstate->TS0+prev_read_TS + nsamps)) {
usleep(100);
usleep(50);
min_TS = fhstate->TS[0];
for (int i=1;i<device->openair0_cfg->rx_num_channels;i++) min_TS = min(min_TS,fhstate->TS[i]);
count++;
@@ -65,13 +65,13 @@ int trx_eth_start(openair0_device *device)
AssertFatal(device->thirdparty_init(device) == 0, "third-party init failed\n");
device->openair0_cfg->samples_per_packet = 256;
eth->num_fd = 1; //max(device->openair0_cfg->rx_num_channels,device->openair0_cfg->tx_num_channels);
printf("Creating %d UDP threads ...\n",device->openair0_cfg->rx_num_channels);
udp_read_t *u[device->openair0_cfg->rx_num_channels];
for (int i=0;i<(device->openair0_cfg->rx_num_channels);i++) {
udp_read_t *u[2];
for (int i=0;i<eth->num_fd;i++) {
u[i] = malloc(sizeof(udp_read_t));
u[i]->thread_id=i;
u[i]->device = device;
threadCreate(&u[i]->pthread,udp_read_thread,u[i],"udp read thread",-1,OAI_PRIORITY_RT_MAX);
printf("UDP Read Thread %d on core %d\n",i,device->openair0_cfg->fh_cores[i]);
threadCreate(&u[i]->pthread,udp_read_thread,u[i],"udp read thread",device->openair0_cfg->fh_cores[i],OAI_PRIORITY_RT_MAX);
}
device->sampling_rate_ratio_n=1;
device->sampling_rate_ratio_d=1;
@@ -112,6 +112,7 @@ int trx_eth_start(openair0_device *device)
}
else AssertFatal(1==0,"num_rb_dl %d not ok with ECPRI\n",device->openair0_cfg->num_rb_dl);
}
#ifdef USE_TX_TPOOL
int threadCnt = device->openair0_cfg->tx_num_channels;
if (threadCnt < 2) LOG_E(PHY,"Number of threads for gNB should be more than 1. Allocated only %d\n",threadCnt);
char pool[80];
@@ -126,6 +127,7 @@ int trx_eth_start(openair0_device *device)
// ULSCH decoder result FIFO
device->respudpTX = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
initNotifiedFIFO(device->respudpTX);
#endif
}
/* initialize socket */
if (eth->flags == ETH_RAW_MODE) {
@@ -211,6 +213,7 @@ int trx_eth_start(openair0_device *device)
if(ethernet_tune (device, RCV_BUF_SIZE,67108864)!=0) return -1;
if(ethernet_tune (device, KERNEL_SND_BUF_MAX_SIZE, 67108864)!=0) return -1;
if(ethernet_tune (device, KERNEL_RCV_BUF_MAX_SIZE, 67108864)!=0) return -1;
if(ethernet_tune (device, TX_Q_LEN, 10000)!=0) return -1;
return 0;
@@ -445,7 +448,7 @@ int ethernet_tune(openair0_device *device,
}
break;
case KERNEL_SND_BUF_MAX_SIZE:
ret=snprintf(system_cmd,sizeof(system_cmd),"sysctl -w net.core.wmem_max=%d;sysctl -w net.core.wmem_default=%d;sysctl -w net.core.netdev_max_backlog=416384;sysctl -w net.core.optmem_max=524288;",value,value);
ret=snprintf(system_cmd,sizeof(system_cmd),"sysctl -w net.core.wmem_max=%d;sysctl -w net.core.wmem_default=%d;sysctl -w net.core.netdev_max_backlog=5000;sysctl -w net.core.optmem_max=524288;",value,value);
if (ret > 0) {
ret=system(system_cmd);
if (ret == -1) {
@@ -487,7 +490,7 @@ int transport_init(openair0_device *device,
eth->compression = ALAW_COMPRESS;
}
eth->num_fd = max(openair0_cfg->rx_num_channels,openair0_cfg->tx_num_channels);
eth->num_fd = 1;
printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU"));
printf("[ETHERNET]: num_fd %d\n",eth->num_fd);