Skip to contentSkip to conversation

Openswan 2.4.9 - tasklet or workqueue ?

DISCUSSION Eran Ben-Avi 2 participants 2 messages Nov 1, 2007 – Nov 5, 2007 Crypto API

lore
Share & tools
lore
#0 lore raw

----- Original Message ----

Quoted 30 lines

From: David McCullough <[email protected]>
To: Eran Ben-Avi <[email protected]>
Cc: [email protected]; [email protected]
Sent: Wednesday, September 26, 2007 12:26:10 PM
Subject: Re: Openswan 2.4.9 - tasklet or workqueue ?

Jivin Eran Ben-Avi lays it down ...

Quoted 13 lines
Quoted 13 lines

Jivin Eran Ben-Avi lays it down ...

Quoted 3 lines

Hi,

I tested IPSec(tunnel mode) routing performance

between 2 GbE ports using packet generator(SMARTBIT)
on ARM 500MHz with latest OCF patched on
Openswan2.4.9 and I noticed the callback functions are using workqueue.

Quoted 1 line

Since RX was performed in NAPI mode with higher

priority then TX (in workqueue), the callback
function(in ipsec_ocf.c) was starved with zero
routing.

Quoted 1 line

The problem was solved after I switched to use

Quoted 8 lines
Quoted 5 lines

tasklet instead of the workqueue.

Quoted 1 line

Is there a room for updating next OCF release ?

Sure, send in a patch. This is against
ocf-linux-20070727 right ?

Yes.
Can you please estimate when next release will be
ready?

Quoted 9 lines

I can probably do one in about a week (offline next week). I could more easily drop a diff since the last release if that helps you out.

I have made a few small changes to your patch so it should be safe on 2.4 systems yet still select tasklets on 2.6 automatically.

Could you have a look at it ? I have done some basic testing here and it seems ok, haven't checked your performance increases yet ;-)

Sorry for the late response.
It seems to be ok. I will test it more intensely in the next few days. Thanks.

Quoted 7 lines

Thanks,
Davidm

Signature · 2 lines
David McCullough,  [email protected],  
Ph:+61

734352815

Quoted 3 lines

Secure Computing - SnapGear
http://www.uCdot.org

http://www.cyberguard.com

Quoted 4 lines

-----Inline Attachment Follows-----

Quoted 8 lines

Index: openswan/linux/include/openswan/ipsec_rcv.h
===================================================================
RCS file: openswan/linux/include/openswan/ipsec_rcv.h,v retrieving revision 1.13
diff -u -r1.13 ipsec_rcv.h
--- openswan/linux/include/openswan/ipsec_rcv.h 26 Jun 2007
06:28:52

-0000 1.13

Quoted 3 lines

+++ openswan/linux/include/openswan/ipsec_rcv.h 26 Sep 2007
14:17:25

-0000

Quoted 10 lines
(quoted diff) +3 -0
@@ -149,6 +149,9 @@
 
 #ifdef CONFIG_KLIPS_OCF
     struct work_struct    workq;
+#ifdef DECLARE_TASKLET
+    struct tasklet_struct    tasklet;
+#endif
 #endif
 #ifndef NET_21
     struct net_device *devp;
Quoted 8 lines

Index: openswan/linux/include/openswan/ipsec_xmit.h
===================================================================
RCS file: openswan/linux/include/openswan/ipsec_xmit.h,v retrieving revision 1.9
diff -u -r1.9 ipsec_xmit.h
--- openswan/linux/include/openswan/ipsec_xmit.h 26 Jun
2007

05:26:25 -0000 1.9

Quoted 3 lines

+++ openswan/linux/include/openswan/ipsec_xmit.h 26 Sep
2007

14:17:25 -0000

Quoted 10 lines
(quoted diff) +3 -0
@@ -140,6 +140,9 @@
     int        next_state;
 #ifdef CONFIG_KLIPS_OCF
     struct work_struct    workq;
+#ifdef DECLARE_TASKLET
+    struct tasklet_struct    tasklet;
+#endif
 #endif
 #ifdef CONFIG_KLIPS_ALG
     struct ipsec_alg_auth *ixt_a;
Quoted 8 lines

Index: openswan/linux/net/ipsec/ipsec_ocf.c
===================================================================
RCS file: openswan/linux/net/ipsec/ipsec_ocf.c,v
retrieving revision 1.27
diff -u -r1.27 ipsec_ocf.c
--- openswan/linux/net/ipsec/ipsec_ocf.c 11 Jul 2007 00:35:01
-0000

    1.27
Quoted 7 lines

+++ openswan/linux/net/ipsec/ipsec_ocf.c 26 Sep 2007 14:17:25 -0000

(quoted diff) +0 -0
@@ -56,7 +56,11 @@
 #define USE_BATCH 1    /* enable batch mode */
 #define USE_CBIMM 1    /* enable immediate callbacks */
 #define FORCE_QS  0    /* force use of queues for continuation

of

state machine */

Quoted 5 lines
(quoted diff) +2 -1
-
+#ifdef DECLARE_TASKLET
+#define USE_TASKLET 1  /* use tasklet for continuation of

state

machine */

Quoted 4 lines
(quoted diff) +2 -0
+#else
+#define USE_TASKLET 0  /* don't use tasklet for continuation of

state

machine */

Quoted 5 lines

+#endif
/*
* Because some OCF operations are synchronous (ie.,
software

encryption)

Quoted 16 lines

* we need to protect ourselves from distructive re-entry. All we do

(quoted diff) +8 -2
@@ -83,15 +87,21 @@
         (*sm)(arg); \
     })
 
-#if FORCE_QS == 0
-    #define PROCESS_NEXT(wq, wqsm, sm, arg) \
+#if USE_TASKLET == 1
+    #define PROCESS_NEXT(this, wqsm, sm) ({ \
+        tasklet_init(&this->tasklet, \
+            (void (*)(unsigned long)) sm, (unsigned long)this); \
+        tasklet_schedule(&this->tasklet); \
+        })
+#elif FORCE_QS == 0
+    #define PROCESS_NEXT(this, wqsm, sm) \
         if (in_interrupt()) { \

Review line 105

Quoted 10 lines
(quoted diff) +2 -3
-            PROCESS_LATER(wq, wqsm, arg); \
+            PROCESS_LATER(this->workq, wqsm, this); \
         } else { \
-            PROCESS_NOW(sm, arg); \
+            PROCESS_NOW(sm, this); \
         }
 #else
-    #define PROCESS_NEXT(wq, wqsm, sm, arg) PROCESS_LATER(wq,
 wqsm,
 

arg)

Review line 107

Quoted 3 lines
(quoted diff) +1 -0
+    #define PROCESS_NEXT(this, wqsm, sm)
 PROCESS_LATER(this->workq,

wqsm, this)

Quoted 21 lines

#endif

/*

(quoted diff) +2 -0
@@ -218,6 +228,7 @@
     return 1;
 }
 
+#if USE_TASKLET == 0
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
 static void
 ipsec_rsm_wq(struct work_struct *work)
@@ -228,6 +239,7 @@
 #else
 #define    ipsec_rsm_wq    ipsec_rsm
 #endif
+#endif /* USE_TASKLET */
 
 static int
 ipsec_ocf_rcv_cb(struct cryptop *crp)
@@ -235,7 +247,6 @@
     struct ipsec_rcv_state *irs = (struct
Quoted 2 lines

ipsec_rcv_state

*)crp->crp_opaque;

Quoted 34 lines
 
     KLIPS_PRINT(debug_rcv, "klips_debug:ipsec_ocf_rcv_cb\n");
(quoted diff) +3 -2
-
     if (irs == NULL) {
         KLIPS_PRINT(debug_rcv, "klips_debug:ipsec_ocf_rcv_cb: "
                 "NULL irs in callback\n");
@@ -273,7 +284,7 @@
     crp = NULL;
 
     /* setup the rest of the processing now */
-    PROCESS_NEXT(irs->workq, ipsec_rsm_wq, ipsec_rsm, irs);
+    PROCESS_NEXT(irs, ipsec_rsm_wq, ipsec_rsm);
     return 0;
 }
 
@@ -396,6 +407,7 @@
     return(IPSEC_RCV_PENDING);
 }
 
+#if USE_TASKLET == 0
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
 static void
 ipsec_xsm_wq(struct work_struct *work)
@@ -406,6 +418,7 @@
 #else
 #define    ipsec_xsm_wq    ipsec_xsm
 #endif
+#endif /* USE_TASKLET */
 
 static int
 ipsec_ocf_xmit_cb(struct cryptop *crp)

Review line 464

Quoted 8 lines
(quoted diff) +1 -1
@@ -445,7 +458,7 @@
     crp = NULL;
 
     /* setup the rest of the processing now */
-    PROCESS_NEXT(ixs->workq, ipsec_xsm_wq, ipsec_xsm, ixs);
+    PROCESS_NEXT(ixs, ipsec_xsm_wq, ipsec_xsm);
     return 0;
 }
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#1 lore raw

Jivin Eran Ben-Avi lays it down ...
...

Quoted 8 lines
Quoted 6 lines

I have made a few small changes to your patch so it should be safe on 2.4 systems yet still select tasklets on 2.6 automatically.

Could you have a look at it ? I have done some basic testing here and it seems ok, haven't checked your performance increases yet ;-)

Sorry for the late response.
It seems to be ok. I will test it more intensely in the next few days.

No problems, I have it sitting there ready to go :-)

Cheers,
Davidm

Quoted 187 lines
Quoted 10 lines

-----Inline Attachment Follows-----

Index: openswan/linux/include/openswan/ipsec_rcv.h
===================================================================
RCS file: openswan/linux/include/openswan/ipsec_rcv.h,v retrieving revision 1.13
diff -u -r1.13 ipsec_rcv.h
--- openswan/linux/include/openswan/ipsec_rcv.h 26 Jun 2007
06:28:52

-0000 1.13

Quoted 3 lines

+++ openswan/linux/include/openswan/ipsec_rcv.h 26 Sep 2007
14:17:25

-0000

Quoted 10 lines
(quoted diff) +3 -0
@@ -149,6 +149,9 @@
 
 #ifdef CONFIG_KLIPS_OCF
     struct work_struct    workq;
+#ifdef DECLARE_TASKLET
+    struct tasklet_struct    tasklet;
+#endif
 #endif
 #ifndef NET_21
     struct net_device *devp;
Quoted 8 lines

Index: openswan/linux/include/openswan/ipsec_xmit.h
===================================================================
RCS file: openswan/linux/include/openswan/ipsec_xmit.h,v retrieving revision 1.9
diff -u -r1.9 ipsec_xmit.h
--- openswan/linux/include/openswan/ipsec_xmit.h 26 Jun
2007

05:26:25 -0000 1.9

Quoted 3 lines

+++ openswan/linux/include/openswan/ipsec_xmit.h 26 Sep
2007

14:17:25 -0000

Quoted 10 lines
(quoted diff) +3 -0
@@ -140,6 +140,9 @@
     int        next_state;
 #ifdef CONFIG_KLIPS_OCF
     struct work_struct    workq;
+#ifdef DECLARE_TASKLET
+    struct tasklet_struct    tasklet;
+#endif
 #endif
 #ifdef CONFIG_KLIPS_ALG
     struct ipsec_alg_auth *ixt_a;
Quoted 8 lines

Index: openswan/linux/net/ipsec/ipsec_ocf.c
===================================================================
RCS file: openswan/linux/net/ipsec/ipsec_ocf.c,v
retrieving revision 1.27
diff -u -r1.27 ipsec_ocf.c
--- openswan/linux/net/ipsec/ipsec_ocf.c 11 Jul 2007 00:35:01
-0000

    1.27
Quoted 7 lines

+++ openswan/linux/net/ipsec/ipsec_ocf.c 26 Sep 2007 14:17:25 -0000

(quoted diff) +0 -0
@@ -56,7 +56,11 @@
 #define USE_BATCH 1    /* enable batch mode */
 #define USE_CBIMM 1    /* enable immediate callbacks */
 #define FORCE_QS  0    /* force use of queues for continuation

of

state machine */

Quoted 5 lines
(quoted diff) +2 -1
-
+#ifdef DECLARE_TASKLET
+#define USE_TASKLET 1  /* use tasklet for continuation of

state

machine */

Quoted 4 lines
(quoted diff) +2 -0
+#else
+#define USE_TASKLET 0  /* don't use tasklet for continuation of

state

machine */

Quoted 5 lines

+#endif
/*
* Because some OCF operations are synchronous (ie.,
software

encryption)

Quoted 16 lines

* we need to protect ourselves from distructive re-entry. All we do

(quoted diff) +8 -2
@@ -83,15 +87,21 @@
         (*sm)(arg); \
     })
 
-#if FORCE_QS == 0
-    #define PROCESS_NEXT(wq, wqsm, sm, arg) \
+#if USE_TASKLET == 1
+    #define PROCESS_NEXT(this, wqsm, sm) ({ \
+        tasklet_init(&this->tasklet, \
+            (void (*)(unsigned long)) sm, (unsigned long)this); \
+        tasklet_schedule(&this->tasklet); \
+        })
+#elif FORCE_QS == 0
+    #define PROCESS_NEXT(this, wqsm, sm) \
         if (in_interrupt()) { \

Review line 105

Quoted 10 lines
(quoted diff) +2 -3
-            PROCESS_LATER(wq, wqsm, arg); \
+            PROCESS_LATER(this->workq, wqsm, this); \
         } else { \
-            PROCESS_NOW(sm, arg); \
+            PROCESS_NOW(sm, this); \
         }
 #else
-    #define PROCESS_NEXT(wq, wqsm, sm, arg) PROCESS_LATER(wq,
 wqsm,
 

arg)

Review line 107

Quoted 3 lines
(quoted diff) +1 -0
+    #define PROCESS_NEXT(this, wqsm, sm)
 PROCESS_LATER(this->workq,

wqsm, this)

Quoted 21 lines

#endif

/*

(quoted diff) +2 -0
@@ -218,6 +228,7 @@
     return 1;
 }
 
+#if USE_TASKLET == 0
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
 static void
 ipsec_rsm_wq(struct work_struct *work)
@@ -228,6 +239,7 @@
 #else
 #define    ipsec_rsm_wq    ipsec_rsm
 #endif
+#endif /* USE_TASKLET */
 
 static int
 ipsec_ocf_rcv_cb(struct cryptop *crp)
@@ -235,7 +247,6 @@
     struct ipsec_rcv_state *irs = (struct
Quoted 2 lines

ipsec_rcv_state

*)crp->crp_opaque;

Quoted 34 lines
 
     KLIPS_PRINT(debug_rcv, "klips_debug:ipsec_ocf_rcv_cb\n");
(quoted diff) +3 -2
-
     if (irs == NULL) {
         KLIPS_PRINT(debug_rcv, "klips_debug:ipsec_ocf_rcv_cb: "
                 "NULL irs in callback\n");
@@ -273,7 +284,7 @@
     crp = NULL;
 
     /* setup the rest of the processing now */
-    PROCESS_NEXT(irs->workq, ipsec_rsm_wq, ipsec_rsm, irs);
+    PROCESS_NEXT(irs, ipsec_rsm_wq, ipsec_rsm);
     return 0;
 }
 
@@ -396,6 +407,7 @@
     return(IPSEC_RCV_PENDING);
 }
 
+#if USE_TASKLET == 0
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
 static void
 ipsec_xsm_wq(struct work_struct *work)
@@ -406,6 +418,7 @@
 #else
 #define    ipsec_xsm_wq    ipsec_xsm
 #endif
+#endif /* USE_TASKLET */
 
 static int
 ipsec_ocf_xmit_cb(struct cryptop *crp)

Review line 464

Quoted 8 lines
(quoted diff) +1 -1
@@ -445,7 +458,7 @@
     crp = NULL;
 
     /* setup the rest of the processing now */
-    PROCESS_NEXT(ixs->workq, ipsec_xsm_wq, ipsec_xsm, ixs);
+    PROCESS_NEXT(ixs, ipsec_xsm_wq, ipsec_xsm);
     return 0;
 }
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Signature · 2 lines
David McCullough,  [email protected],   Ph:+61 734352815
Secure Computing - SnapGear  http://www.uCdot.org http://www.cyberguard.com