cuda-packet-batcher timeout supports float values

remotes/origin/master-1.1.x
Martin Beyer 16 years ago committed by Victor Julien
parent 7dd2392dea
commit 621815ded0

@ -109,6 +109,9 @@ static MpmCudaConf *profile = NULL;
* processing on the GPU */ * processing on the GPU */
static int queue_buffer = 0; static int queue_buffer = 0;
/* struct to configure the SIG_ALRM frequency. */
static struct itimerval itimer = {{0, 0}, {0, 0}};
static int unittest_mode = 0; static int unittest_mode = 0;
/** /**
@ -124,9 +127,9 @@ static int unittest_mode = 0;
*/ */
static void SCCudaPBSetQueueBufferFlag(int signum) static void SCCudaPBSetQueueBufferFlag(int signum)
{ {
SCLogDebug("Cuda Packet Batche alarm generated after %d seconds. Set the" SCLogDebug("Cuda Packet Batche alarm generated after %f seconds. Set the"
"queue_buffer flag and signal the cuda TM inq.", "queue_buffer flag and signal the cuda TM inq.",
SC_CUDA_PB_BATCHER_ALARM_TIME); profile->batching_timeout);
queue_buffer = 1; queue_buffer = 1;
SCCondSignal(&((&trans_q[tmq_batcher_inq->id])->cond_q)); SCCondSignal(&((&trans_q[tmq_batcher_inq->id])->cond_q));
@ -148,9 +151,29 @@ static void SCCudaPBSetBatcherAlarmTimeHandler()
action.sa_flags = 0; action.sa_flags = 0;
sigaction(SIGALRM, &action, 0); sigaction(SIGALRM, &action, 0);
itimer.it_value.tv_sec = profile->batching_timeout;
itimer.it_value.tv_usec = (profile->batching_timeout
- (int32_t) profile->batching_timeout) * 1000000;
return; return;
} }
/**
* \internal
* \brief Reset the batcher alarm.
*/
static inline void SCCudaPBResetBatcherAlarm()
{
queue_buffer = 0;
/* if we are running unittests, don't set the alarm handler. It will only
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
/* \todo We could update itimer dynamically based on the traffic */
setitimer(ITIMER_REAL, &itimer, NULL);
}
}
/** /**
* \internal * \internal
* \brief Used to retrieve the Signature Group Head for a packet. * \brief Used to retrieve the Signature Group Head for a packet.
@ -587,13 +610,9 @@ TmEcode SCCudaPBThreadInit(ThreadVars *tv, void *initdata, void **data)
/* set the SIG_ALRM handler */ /* set the SIG_ALRM handler */
SCCudaPBSetBatcherAlarmTimeHandler(); SCCudaPBSetBatcherAlarmTimeHandler();
/* if we are running unittests, don't set the alarm handler. It will only /* Set the alarm time limit during which the batcher thread would
* cause a seg fault if the tests take too long */ * buffer packets */
if (!unittest_mode) { SCCudaPBResetBatcherAlarm();
/* Set the alarm time limit during which the batcher thread would
* buffer packets */
alarm(profile->batching_timeout);
}
return TM_ECODE_OK; return TM_ECODE_OK;
} }
@ -615,20 +634,15 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
#define ALIGN_UP(offset, alignment) \ #define ALIGN_UP(offset, alignment) \
(offset) = ((offset) + (alignment) - 1) & ~((alignment) - 1) (offset) = ((offset) + (alignment) - 1) & ~((alignment) - 1)
SCCudaPBThreadCtx *tctx = data;
/* ah. we have been signalled that we crossed the time limit within which we /* ah. we have been signalled that we crossed the time limit within which we
* need to buffer packets. Let us queue the buffer to the GPU */ * need to buffer packets. Let us queue the buffer to the GPU */
if (queue_buffer) { if (queue_buffer) {
SCLogDebug("Cuda packet buffer TIME limit exceeded. Buffering packet " SCLogDebug("Cuda packet buffer TIME limit exceeded. Buffering packet "
"buffer and reseting the alarm"); "buffer and reseting the alarm");
queue_buffer = 0; SCCudaPBQueueBuffer(tctx);
SCLogDebug("Cuda packet buffer TIME limit exceeded. Buffering packet " SCCudaPBResetBatcherAlarm();
"buffer and reseting the alarm");
SCCudaPBQueueBuffer(data);
/* if we are running unittests, don't set the alarm handler. It will only
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
alarm(profile->batching_timeout);
}
} }
/* this is possible, since we are using a custom slot function that calls this /* this is possible, since we are using a custom slot function that calls this
@ -649,7 +663,6 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
return TM_ECODE_OK; return TM_ECODE_OK;
} }
SCCudaPBThreadCtx *tctx = data;
/* the packets buffer */ /* the packets buffer */
SCCudaPBPacketsBuffer *pb = (SCCudaPBPacketsBuffer *)tctx->curr_pb; SCCudaPBPacketsBuffer *pb = (SCCudaPBPacketsBuffer *)tctx->curr_pb;
/* the previous packet which has been buffered into the packets_buffer */ /* the previous packet which has been buffered into the packets_buffer */
@ -782,17 +795,12 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
* left in the buffer or we have been informed that we have hit the time limit * left in the buffer or we have been informed that we have hit the time limit
* to queue the buffer */ * to queue the buffer */
if ( (pb->nop_in_buffer == buffer_packet_threshhold) || queue_buffer) { if ( (pb->nop_in_buffer == buffer_packet_threshhold) || queue_buffer) {
queue_buffer = 0;
SCLogDebug("Either we have hit the threshold limit for packets(i.e. we " SCLogDebug("Either we have hit the threshold limit for packets(i.e. we "
"have %d packets limit) OR we have exceeded the buffering " "have %d packets limit) OR we have exceeded the buffering "
"time limit. Buffering the packet buffer and reseting the " "time limit. Buffering the packet buffer and reseting the "
"alarm.", buffer_packet_threshhold); "alarm.", buffer_packet_threshhold);
SCCudaPBQueueBuffer(tctx); SCCudaPBQueueBuffer(tctx);
/* if we are running unittests, don't set the alarm handler. It will only SCCudaPBResetBatcherAlarm();
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
alarm(profile->batching_timeout);
}
} }
return TM_ECODE_OK; return TM_ECODE_OK;

@ -555,8 +555,8 @@ MpmCudaConf *MpmCudaConfParse(void)
SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry for " SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry for "
"cuda.mpm.batching_timeout. Either NULL or empty"); "cuda.mpm.batching_timeout. Either NULL or empty");
} else { } else {
profile->batching_timeout = atoi(batching_timeout); profile->batching_timeout = atof(batching_timeout);
if (profile->batching_timeout <= 0) { if (profile->batching_timeout < 0.000001) {
SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry for " SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry for "
"cuda.mpm.batching_timeout - %s", batching_timeout); "cuda.mpm.batching_timeout - %s", batching_timeout);
profile->batching_timeout = MPM_BATCHING_TIMEOUT; profile->batching_timeout = MPM_BATCHING_TIMEOUT;

@ -196,7 +196,7 @@ typedef struct MpmCudaConf_ {
int32_t packet_buffer_limit; int32_t packet_buffer_limit;
int16_t packet_size_limit; int16_t packet_size_limit;
int8_t packet_buffers; int8_t packet_buffers;
int8_t batching_timeout; double batching_timeout;
int8_t page_locked; int8_t page_locked;
int8_t device_id; int8_t device_id;
} MpmCudaConf; } MpmCudaConf;

Loading…
Cancel
Save