Skip to content

LwIP: make TCPIP_THREAD_PRIO configurable #10980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2019
Merged

LwIP: make TCPIP_THREAD_PRIO configurable #10980

merged 1 commit into from
Aug 5, 2019

Conversation

vmedcy
Copy link
Contributor

@vmedcy vmedcy commented Jul 5, 2019

Description

Allow targets override TCPIP_THREAD_PRIO from features/lwipstack/mbed_lib.json.
Some PSoC 6 applications require TCPIP_THREAD_PRIO=osPriorityHigh to operate correctly.

Pull request type

[ ] Fix
[X] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

@ciarmcom ciarmcom requested review from a team July 5, 2019 17:00
@ciarmcom
Copy link
Member

ciarmcom commented Jul 5, 2019

@vmedcy, thank you for your changes.
@ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit wary that if you find yourself needing to change priority you may have worse problems - I usually find thread priority isn't the answer. But may as well let people fiddle.

Just editorial suggestions.

@@ -120,6 +120,10 @@
"help": "Stack size for lwip TCPIP thread",
"value": 1200
},
"tcpip-thread-priority": {
"help": "priority of lwip TCPIP thread",
"value": 24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this to be set by name - make it "osPriorityNormal". 24 is a bit vague.

Strings work fine here - a JSON string becomes C token(s). (If you wanted a C string you'd need to do "\"string\"").

@@ -120,6 +120,10 @@
"help": "Stack size for lwip TCPIP thread",
"value": 1200
},
"tcpip-thread-priority": {
"help": "priority of lwip TCPIP thread",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Priority of..." (capital)

@@ -111,7 +111,11 @@
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8)
#endif

#ifdef MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment with the default value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd kind of prefer not to have a default value here. This isn't a case where we need null in the JSON to mean "do something sensible".

We could just put the "osPriorityNormal" in the default JSON file, and have no #ifdef here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am fine with "osPriorityNormal" in the default mbed_lib.json, with no #ifdef in header file.

balajicyp added a commit to balajicyp/mbed-os that referenced this pull request Jul 16, 2019
changes done based on review for
ARMmbed#10980
@SeppoTakalo
Copy link
Contributor

I would like to have better understanding why this fixes any problems.

Having need to touch priorities to get some platforms to pass tests is a symptom of unstable platforms. Not a proper fix.

Network stack interfaces in Mbed OS effectively operate in event-based system. Unless other drivers consume 100% of CPU, then there should be eventually enough time to pass data through network stack. Having a need to raise network stack priority to high sounds like platform has busy-loops running on normal priority threads.
If those busy-loops are fixed, this need should go away, and system would throttle normally.

@balajicyp
Copy link
Contributor

Hi Seppo,

Cypress needs the LwIP TCP IP Thread priority configurable to set it to osPriorityHigh for some high throughput applicaitons such as iperf ( where the Throughput is sent at high rate of the order 40Mbps) from remote PC to Device.

We have several threads most importantly we have internal thread which gets signalled when SDIO IRQ is triggerred this is responsible for reading SDIO bus data from WLAN chip and this thread allocates its memory for the packet using pbuf ( LWIP buffer), this thread runs at osPriorityHigh, the LWIP threads gets data (UDP traffic) and it keeps the data in pbuf ( RAW pool) until the application reads the data, now if the application is slower running at lower priority then we see the LWIP TCP IP priroity running at < osPriorityHigh running out of its memory pool buffers.

Thanks
Balaji

@SeppoTakalo
Copy link
Contributor

Ah, so effectively you are just optimising the throughput of the system.

@SeppoTakalo
Copy link
Contributor

I'll start the CI tests.

@mbed-ci
Copy link

mbed-ci commented Aug 2, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants