* [dpdk-dev] Thread safety in rte_acl @ 2018-01-08 5:42 =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 11:42 ` Ananyev, Konstantin 0 siblings, 1 reply; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 5:42 UTC (permalink / raw) To: =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 246 bytes --] Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? 2. Is it safe that one thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] Thread safety in rte_acl 2018-01-08 5:42 [dpdk-dev] Thread safety in rte_acl =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 11:42 ` Ananyev, Konstantin 2018-01-08 11:59 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0?= =?gb18030?q?e=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 0 siblings, 1 reply; 13+ messages in thread From: Ananyev, Konstantin @ 2018-01-08 11:42 UTC (permalink / raw) To: 1534057243, dev > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0?= =?gb18030?q?e=5Facl?= 2018-01-08 11:42 ` Ananyev, Konstantin @ 2018-01-08 11:59 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 12:17 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ananyev, Konstantin 2018-01-08 13:06 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu 0 siblings, 2 replies; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 11:59 UTC (permalink / raw) To: =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1141 bytes --] >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to match rule, does it need to add lock? if not, is there other method to implement this safely? ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] 回复:RE: Thread safety in rte_acl 2018-01-08 11:59 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0?= =?gb18030?q?e=5Facl?= =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 12:17 ` Ananyev, Konstantin 2018-01-08 13:43 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiAgVGhyZWFkIHNh?= =?gb18030?q?fety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 13:06 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu 1 sibling, 2 replies; 13+ messages in thread From: Ananyev, Konstantin @ 2018-01-08 12:17 UTC (permalink / raw) To: 1534057243, dev >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory(struct rte_acl_ctx), one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; 发送时间: 2018年1月8日(星期一) 晚上7:42 收件人: "真我风采"<1534057243@qq.com>;"dev"<dev@dpdk.org>; 主题: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiAgVGhyZWFkIHNh?= =?gb18030?q?fety_in_rte=5Facl?= 2018-01-08 12:17 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ananyev, Konstantin @ 2018-01-08 13:43 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= 1 sibling, 0 replies; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 13:43 UTC (permalink / raw) To: =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 3174 bytes --] >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin thanks very much ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ8:17 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiAgVGhyZWFkIHNh?= =?gb18030?q?fety_in_rte=5Facl?= 2018-01-08 12:17 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ananyev, Konstantin 2018-01-08 13:43 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiAgVGhyZWFkIHNh?= =?gb18030?q?fety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 4:00 ` [dpdk-dev] 回复:RE: 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu 2018-01-10 11:46 ` Ananyev, Konstantin 1 sibling, 2 replies; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-10 2:50 UTC (permalink / raw) To: =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?UmFtaWEsIEthbm5hbiBCYWJ1?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2993 bytes --] >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ8:17 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] 回复:RE: 回复:RE: Thread safety in rte_acl 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-10 4:00 ` Ramia, Kannan Babu 2018-01-10 11:46 ` Ananyev, Konstantin 1 sibling, 0 replies; 13+ messages in thread From: Ramia, Kannan Babu @ 2018-01-10 4:00 UTC (permalink / raw) To: 1534057243, Ananyev, Konstantin, dev The way the application is written assumes there will be a transition phase where few threads will have OLD ACL results for the packets that are currently handled, but once those set is flushed out all the new set of packets will be back to the active set. So the system will be consistent after this transition period. PS: Please also look at the vCG-NAT and vFW to see how this could be achieved in the application. Regards Kannan Babu From: 真我风采 [mailto:1534057243@qq.com] Sent: Wednesday, January 10, 2018 8:20 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: 回复:RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上8:17 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory(struct rte_acl_ctx), one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上7:42 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] 回复:RE: 回复:RE: Thread safety in rte_acl 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 4:00 ` [dpdk-dev] 回复:RE: 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu @ 2018-01-10 11:46 ` Ananyev, Konstantin 2018-01-15 2:01 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTog?= =?gb18030?q?_Thread_safety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 1 sibling, 1 reply; 13+ messages in thread From: Ananyev, Konstantin @ 2018-01-10 11:46 UTC (permalink / raw) To: 1534057243, Ramia, Kannan Babu, dev The simplest one would be to have rwlock to read/write active index. Also something like that I think should work (just a sample, not tested or compiled): struct acl { rte_acl_ctx *ctx[2]; rte_atomic32_t use; uint32_t active; }; update(struct acl *acl, …) { <update/rebuild non-acive copy> /* make sure all stores are visible */ rte_smp_wmb(); uint32_t active = acl->active; acl->active = active ^ 1; /* to avoid store/load reorder */ rte_smp_mb(); while (rte_atomic32_read(&acl->use) != 0) rte_pause(); <free old active copy here> } classify(struct acl *acl, …) { rte_atomic32_inc(&acl->use); rte_acl_classify(acl->ctx[acl->active}, …); rte_atomic32_dec(&acl->use); } Konstantin From: 真我风采 [mailto:1534057243@qq.com] Sent: Wednesday, January 10, 2018 2:50 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: 回复:RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上8:17 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory(struct rte_acl_ctx), one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上7:42 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTog?= =?gb18030?q?_Thread_safety_in_rte=5Facl?= 2018-01-10 11:46 ` Ananyev, Konstantin @ 2018-01-15 2:01 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-15 10:34 ` [dpdk-dev] 回复:RE: 回复:RE: 回复:RE: Thread safety in rte_acl Ananyev, Konstantin 0 siblings, 1 reply; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-15 2:01 UTC (permalink / raw) To: =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?UmFtaWEsIEthbm5hbiBCYWJ1?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 5103 bytes --] Thanks for providing idea to me! I will refer to that. I have another way feeling that it should works too. switchover active and standby pointer on forward plane, rather than on control plane. when update ctx in control plane(add rule, build on standby, meanwhile add rule on active not build), set flag=1, and on forward plane if flag==1 then switchover and set flag=0. ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ10ÈÕ(ÐÇÆÚÈý) ÍíÉÏ7:46 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"Ramia, Kannan Babu"<kannan.babu.ramia@intel.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl The simplest one would be to have rwlock to read/write active index. Also something like that I think should work (just a sample, not tested or compiled): struct acl { rte_acl_ctx *ctx[2]; rte_atomic32_t use; uint32_t active; }; update(struct acl *acl, ¡) { <update/rebuild non-acive copy> /* make sure all stores are visible */ rte_smp_wmb(); uint32_t active = acl->active; acl->active = active ^ 1; /* to avoid store/load reorder */ rte_smp_mb(); while (rte_atomic32_read(&acl->use) != 0) rte_pause(); <free old active copy here> } classify(struct acl *acl, ¡) { rte_atomic32_inc(&acl->use); rte_acl_classify(acl->ctx[acl->active}, ¡); rte_atomic32_dec(&acl->use); } Konstantin From: ÕæÎÒ·ç²É [mailto:1534057243@qq.com] Sent: Wednesday, January 10, 2018 2:50 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ8:17 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] 回复:RE: 回复:RE: 回复:RE: Thread safety in rte_acl 2018-01-15 2:01 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTog?= =?gb18030?q?_Thread_safety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-15 10:34 ` Ananyev, Konstantin 2018-01-15 10:41 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTogu9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0ZV9hY2w=?= =?gb18030?B?1ebO0rfnssk=?= 0 siblings, 1 reply; 13+ messages in thread From: Ananyev, Konstantin @ 2018-01-15 10:34 UTC (permalink / raw) To: 1534057243, Ramia, Kannan Babu, dev That should work too I think… But in that case your data-plane would have to grab exclusive lock (in case you have multiple threads/processes) doing classify() over the same context in parallel. Konstantin From: 真我风采 [mailto:1534057243@qq.com] Sent: Monday, January 15, 2018 2:01 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: 回复:RE: 回复:RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl Thanks for providing idea to me! I will refer to that. I have another way feeling that it should works too. switchover active and standby pointer on forward plane, rather than on control plane. when update ctx in control plane(add rule, build on standby, meanwhile add rule on active not build), set flag=1, and on forward plane if flag==1 then switchover and set flag=0. ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月10日(星期三) 晚上7:46 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"Ramia, Kannan Babu"<kannan.babu.ramia@intel.com<mailto:kannan.babu.ramia@intel.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: 回复:RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl The simplest one would be to have rwlock to read/write active index. Also something like that I think should work (just a sample, not tested or compiled): struct acl { rte_acl_ctx *ctx[2]; rte_atomic32_t use; uint32_t active; }; update(struct acl *acl, …) { <update/rebuild non-acive copy> /* make sure all stores are visible */ rte_smp_wmb(); uint32_t active = acl->active; acl->active = active ^ 1; /* to avoid store/load reorder */ rte_smp_mb(); while (rte_atomic32_read(&acl->use) != 0) rte_pause(); <free old active copy here> } classify(struct acl *acl, …) { rte_atomic32_inc(&acl->use); rte_acl_classify(acl->ctx[acl->active}, …); rte_atomic32_dec(&acl->use); } Konstantin From: 真我风采 [mailto:1534057243@qq.com] Sent: Wednesday, January 10, 2018 2:50 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com<mailto:kannan.babu.ramia@intel.com>>; dev <dev@dpdk.org<mailto:dev@dpdk.org>> Subject: 回复:RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上8:17 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: 回复:RE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory(struct rte_acl_ctx), one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>; 发送时间: 2018年1月8日(星期一) 晚上7:42 收件人: "真我风采"<1534057243@qq.com<mailto:1534057243@qq.com>>;"dev"<dev@dpdk.org<mailto:dev@dpdk.org>>; 主题: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTogu9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0ZV9hY2w=?= 2018-01-15 10:34 ` [dpdk-dev] 回复:RE: 回复:RE: 回复:RE: Thread safety in rte_acl Ananyev, Konstantin @ 2018-01-15 10:41 ` =?gb18030?B?1ebO0rfnssk=?= 0 siblings, 0 replies; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-15 10:41 UTC (permalink / raw) To: =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?UmFtaWEsIEthbm5hbiBCYWJ1?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 6202 bytes --] Yes£¬ but now there is only one process doing classify() in our case, so it just suitable. thanks !!! ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ15ÈÕ(ÐÇÆÚÒ») ÍíÉÏ6:34 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"Ramia, Kannan Babu"<kannan.babu.ramia@intel.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl That should work too I think¡ But in that case your data-plane would have to grab exclusive lock (in case you have multiple threads/processes) doing classify() over the same context in parallel. Konstantin From: ÕæÎÒ·ç²É [mailto:1534057243@qq.com] Sent: Monday, January 15, 2018 2:01 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: »Ø¸´£ºRE: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl Thanks for providing idea to me! I will refer to that. I have another way feeling that it should works too. switchover active and standby pointer on forward plane, rather than on control plane. when update ctx in control plane(add rule, build on standby, meanwhile add rule on active not build), set flag=1, and on forward plane if flag==1 then switchover and set flag=0. ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ10ÈÕ(ÐÇÆÚÈý) ÍíÉÏ7:46 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"Ramia, Kannan Babu"<kannan.babu.ramia@intel.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl The simplest one would be to have rwlock to read/write active index. Also something like that I think should work (just a sample, not tested or compiled): struct acl { rte_acl_ctx *ctx[2]; rte_atomic32_t use; uint32_t active; }; update(struct acl *acl, ¡) { <update/rebuild non-acive copy> /* make sure all stores are visible */ rte_smp_wmb(); uint32_t active = acl->active; acl->active = active ^ 1; /* to avoid store/load reorder */ rte_smp_mb(); while (rte_atomic32_read(&acl->use) != 0) rte_pause(); <free old active copy here> } classify(struct acl *acl, ¡) { rte_atomic32_inc(&acl->use); rte_acl_classify(acl->ctx[acl->active}, ¡); rte_atomic32_dec(&acl->use); } Konstantin From: ÕæÎÒ·ç²É [mailto:1534057243@qq.com] Sent: Wednesday, January 10, 2018 2:50 AM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Ramia, Kannan Babu <kannan.babu.ramia@intel.com>; dev <dev@dpdk.org> Subject: »Ø¸´£ºRE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >Yes, you'll need some sort of synchronization. >Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. >Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. >Then you can do classify() on active one while doing add_rules/build on second one. >Then when the second one is re-build you can switch an active index to it. >I think librte_table uses that method. >Of course you might need a reference counter or some other way to deternine that >no-one is using old copy anymore and it is free to update it again. >Konstantin I have look at the source of samplevnf as below doc, it switchover active and standby directlt without ensuring old copy not used anymore. https://github.com/opnfv/samplevnf/blob/master/VNFs/vACL/pipeline/pipeline_acl.c: cmd_acl_applyruleset_parsed So, my question is that how to ensure that no-one is using old copy anymore ? thanks! ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ8:17 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: »Ø¸´£ºRE: [dpdk-dev] Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. > In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to > match rule, does it need to add lock? if not, is there other method to implement this safely? Yes, you'll need some sort of synchronization. Lock (or rwlock) is one option, but as build could take quite long time - probably not the best one. Another way - have a struct cthat ontains pointers to 2 ctx and an index for active one. Then you can do classify() on active one while doing add_rules/build on second one. Then when the second one is re-build you can switch an active index to it. I think librte_table uses that method. Of course you might need a reference counter or some other way to deternine that no-one is using old copy anymore and it is free to update it again. Konstantin ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] 回复:RE: Thread safety in rte_acl 2018-01-08 11:59 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0?= =?gb18030?q?e=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 12:17 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ananyev, Konstantin @ 2018-01-08 13:06 ` Ramia, Kannan Babu 2018-01-08 13:42 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICC72Li0o7pSRTogIFRocmVhZCBz?= =?gb18030?q?afety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 1 sibling, 1 reply; 13+ messages in thread From: Ramia, Kannan Babu @ 2018-01-08 13:06 UTC (permalink / raw) To: 1534057243, Ananyev, Konstantin, dev You can look at the source of anyone of the applications in samplevnf project in OPNFV which uses the active/shadow method for dynamically modifying the rules and applying them. Regards Kannan Babu -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of ???? Sent: Monday, January 8, 2018 5:30 PM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev <dev@dpdk.org> Subject: [dpdk-dev] 回复:RE: Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. In my case, there are two process sharing hugepage memory(struct rte_acl_ctx), one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to match rule, does it need to add lock? if not, is there other method to implement this safely? ------------------ 原始邮件 ------------------ 发件人: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; 发送时间: 2018年1月8日(星期一) 晚上7:42 收件人: "真我风采"<1534057243@qq.com>;"dev"<dev@dpdk.org>; 主题: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICC72Li0o7pSRTogIFRocmVhZCBz?= =?gb18030?q?afety_in_rte=5Facl?= 2018-01-08 13:06 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu @ 2018-01-08 13:42 ` =?gb18030?B?1ebO0rfnssk=?= 0 siblings, 0 replies; 13+ messages in thread From: =?gb18030?B?1ebO0rfnssk=?= @ 2018-01-08 13:42 UTC (permalink / raw) To: =?gb18030?B?UmFtaWEsIEthbm5hbiBCYWJ1?=, =?gb18030?B?QW5hbnlldiwgS29uc3RhbnRpbg==?=, =?gb18030?B?ZGV2?= [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1961 bytes --] Thanks very much! ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ramia, Kannan Babu";<kannan.babu.ramia@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ9:06 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"Ananyev, Konstantin"<konstantin.ananyev@intel.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] »Ø¸´£ºRE: Thread safety in rte_acl You can look at the source of anyone of the applications in samplevnf project in OPNFV which uses the active/shadow method for dynamically modifying the rules and applying them. Regards Kannan Babu -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of ???? Sent: Monday, January 8, 2018 5:30 PM To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev <dev@dpdk.org> Subject: [dpdk-dev] »Ø¸´£ºRE: Thread safety in rte_acl >> 2. Is it safe that one >> thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, >Just add new rules is safe, but applying them (calling rte_acl_build()) is not. In my case, there are two process sharing hugepage memory£¨struct rte_acl_ctx£©, one process call 'rte_acl_build' to add and apply rule, another process call frequently 'rte_acl_classify' to match rule, does it need to add lock? if not, is there other method to implement this safely? ------------------ ÔʼÓʼþ ------------------ ·¢¼þÈË: "Ananyev, Konstantin";<konstantin.ananyev@intel.com>; ·¢ËÍʱ¼ä: 2018Äê1ÔÂ8ÈÕ(ÐÇÆÚÒ») ÍíÉÏ7:42 ÊÕ¼þÈË: "ÕæÎÒ·ç²É"<1534057243@qq.com>;"dev"<dev@dpdk.org>; Ö÷Ìâ: RE: [dpdk-dev] Thread safety in rte_acl > > Hi, I have two questions : 1. Is it safe that multiple threads will run "rte_acl_classify" in parallel (on the same ctx )? Yes. > 2. Is it safe that one > thread will run "rte_acl_classify" when another thread tries to add new rules to same ctx? thanks, Just add new rules is safe, but applying them (calling rte_acl_build()) is not. Konstantin ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-01-15 10:41 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-01-08 5:42 [dpdk-dev] Thread safety in rte_acl =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 11:42 ` Ananyev, Konstantin 2018-01-08 11:59 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0?= =?gb18030?q?e=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 12:17 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ananyev, Konstantin 2018-01-08 13:43 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiAgVGhyZWFkIHNh?= =?gb18030?q?fety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 2:50 ` =?gb18030?B?1ebO0rfnssk=?= 2018-01-10 4:00 ` [dpdk-dev] 回复:RE: 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu 2018-01-10 11:46 ` Ananyev, Konstantin 2018-01-15 2:01 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTog?= =?gb18030?q?_Thread_safety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-15 10:34 ` [dpdk-dev] 回复:RE: 回复:RE: 回复:RE: Thread safety in rte_acl Ananyev, Konstantin 2018-01-15 10:41 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ILvYuLSjulJFOiC72Li0o7pSRTogu9i4tKO6UkU6ICBUaHJlYWQgc2FmZXR5IGluIHJ0ZV9hY2w=?= =?gb18030?B?1ebO0rfnssk=?= 2018-01-08 13:06 ` [dpdk-dev] 回复:RE: Thread safety in rte_acl Ramia, Kannan Babu 2018-01-08 13:42 ` [dpdk-dev] =?gb18030?b?u9i4tKO6UkU6ICC72Li0o7pSRTogIFRocmVhZCBz?= =?gb18030?q?afety_in_rte=5Facl?= =?gb18030?B?1ebO0rfnssk=?=
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).