* [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation
@ 2025-04-17 3:48 Kiran K
2025-04-17 4:38 ` [v2] " bluez.test.bot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kiran K @ 2025-04-17 3:48 UTC (permalink / raw)
To: linux-bluetooth
Cc: ravishankar.srivatsa, chethan.tumkur.narayan,
chandrashekar.devegowda, vijay.satija, Kiran K
Reuse the skb buffer provided by the PCIe driver to pass it onto the
stack, instead of copying it to a new skb.
Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Signed-off-by: Kiran K <kiran.k@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 33 ++++++++++++--------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index e0b50513403f..b73928e38d34 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -947,8 +947,10 @@ static int btintel_pcie_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
/* This is a debug event that comes from IML and OP image when it
* starts execution. There is no need pass this event to stack.
*/
- if (skb->data[2] == 0x97)
+ if (skb->data[2] == 0x97) {
+ hci_recv_diag(hdev, skb);
return 0;
+ }
}
return hci_recv_frame(hdev, skb);
@@ -964,7 +966,6 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data,
u8 pkt_type;
u16 plen;
u32 pcie_pkt_type;
- struct sk_buff *new_skb;
void *pdata;
struct hci_dev *hdev = data->hdev;
@@ -1041,24 +1042,20 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data,
bt_dev_dbg(hdev, "pkt_type: 0x%2.2x len: %u", pkt_type, plen);
- new_skb = bt_skb_alloc(plen, GFP_ATOMIC);
- if (!new_skb) {
- bt_dev_err(hdev, "Failed to allocate memory for skb of len: %u",
- skb->len);
- ret = -ENOMEM;
- goto exit_error;
- }
-
- hci_skb_pkt_type(new_skb) = pkt_type;
- skb_put_data(new_skb, skb->data, plen);
+ hci_skb_pkt_type(skb) = pkt_type;
hdev->stat.byte_rx += plen;
+ skb_trim(skb, plen);
if (pcie_pkt_type == BTINTEL_PCIE_HCI_EVT_PKT)
- ret = btintel_pcie_recv_event(hdev, new_skb);
+ ret = btintel_pcie_recv_event(hdev, skb);
else
- ret = hci_recv_frame(hdev, new_skb);
+ ret = hci_recv_frame(hdev, skb);
+ skb = NULL; /* skb is freed in the callee */
exit_error:
+ if (skb)
+ kfree_skb(skb);
+
if (ret)
hdev->stat.err_rx++;
@@ -1192,8 +1189,6 @@ static void btintel_pcie_rx_work(struct work_struct *work)
struct btintel_pcie_data *data = container_of(work,
struct btintel_pcie_data, rx_work);
struct sk_buff *skb;
- int err;
- struct hci_dev *hdev = data->hdev;
if (test_bit(BTINTEL_PCIE_HWEXP_INPROGRESS, &data->flags)) {
/* Unlike usb products, controller will not send hardware
@@ -1214,11 +1209,7 @@ static void btintel_pcie_rx_work(struct work_struct *work)
/* Process the sk_buf in queue and send to the HCI layer */
while ((skb = skb_dequeue(&data->rx_skb_q))) {
- err = btintel_pcie_recv_frame(data, skb);
- if (err)
- bt_dev_err(hdev, "Failed to send received frame: %d",
- err);
- kfree_skb(skb);
+ btintel_pcie_recv_frame(data, skb);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation
2025-04-17 3:48 [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation Kiran K
@ 2025-04-17 4:38 ` bluez.test.bot
2025-04-17 5:04 ` [PATCH v2] " Paul Menzel
2025-04-18 14:00 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-04-17 4:38 UTC (permalink / raw)
To: linux-bluetooth, kiran.k
[-- Attachment #1: Type: text/plain, Size: 1949 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=954259
---Test result---
Test Summary:
CheckPatch PENDING 0.31 seconds
GitLint PENDING 0.23 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 24.66 seconds
CheckAllWarning PASS 26.92 seconds
CheckSparse PASS 37.45 seconds
BuildKernel32 PASS 26.14 seconds
TestRunnerSetup PASS 457.93 seconds
TestRunner_l2cap-tester PASS 25.54 seconds
TestRunner_iso-tester PASS 34.66 seconds
TestRunner_bnep-tester PASS 6.88 seconds
TestRunner_mgmt-tester PASS 136.85 seconds
TestRunner_rfcomm-tester PASS 16.27 seconds
TestRunner_sco-tester PASS 17.95 seconds
TestRunner_ioctl-tester PASS 17.29 seconds
TestRunner_mesh-tester FAIL 6.28 seconds
TestRunner_smp-tester PASS 10.42 seconds
TestRunner_userchan-tester PASS 9.44 seconds
IncrementalBuild PENDING 0.72 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 2 Failed 0.119 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation
2025-04-17 3:48 [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation Kiran K
2025-04-17 4:38 ` [v2] " bluez.test.bot
@ 2025-04-17 5:04 ` Paul Menzel
2025-04-18 14:00 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Paul Menzel @ 2025-04-17 5:04 UTC (permalink / raw)
To: Kiran K
Cc: linux-bluetooth, ravishankar.srivatsa, chethan.tumkur.narayan,
chandrashekar.devegowda, vijay.satija
Dear Kiran,
Thank you for your patch.
Am 17.04.25 um 05:48 schrieb Kiran K:
> Reuse the skb buffer provided by the PCIe driver to pass it onto the
> stack, instead of copying it to a new skb.
Does `scripts/bloat-o-meter` verify, that the optimization worked?
> Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
> Signed-off-by: Kiran K <kiran.k@intel.com>
> ---
> drivers/bluetooth/btintel_pcie.c | 33 ++++++++++++--------------------
> 1 file changed, 12 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
> index e0b50513403f..b73928e38d34 100644
> --- a/drivers/bluetooth/btintel_pcie.c
> +++ b/drivers/bluetooth/btintel_pcie.c
> @@ -947,8 +947,10 @@ static int btintel_pcie_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
> /* This is a debug event that comes from IML and OP image when it
> * starts execution. There is no need pass this event to stack.
> */
> - if (skb->data[2] == 0x97)
> + if (skb->data[2] == 0x97) {
> + hci_recv_diag(hdev, skb);
> return 0;
> + }
> }
>
> return hci_recv_frame(hdev, skb);
> @@ -964,7 +966,6 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data,
> u8 pkt_type;
> u16 plen;
> u32 pcie_pkt_type;
> - struct sk_buff *new_skb;
> void *pdata;
> struct hci_dev *hdev = data->hdev;
>
> @@ -1041,24 +1042,20 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data,
>
> bt_dev_dbg(hdev, "pkt_type: 0x%2.2x len: %u", pkt_type, plen);
>
> - new_skb = bt_skb_alloc(plen, GFP_ATOMIC);
> - if (!new_skb) {
> - bt_dev_err(hdev, "Failed to allocate memory for skb of len: %u",
> - skb->len);
> - ret = -ENOMEM;
> - goto exit_error;
> - }
> -
> - hci_skb_pkt_type(new_skb) = pkt_type;
> - skb_put_data(new_skb, skb->data, plen);
> + hci_skb_pkt_type(skb) = pkt_type;
> hdev->stat.byte_rx += plen;
> + skb_trim(skb, plen);
>
> if (pcie_pkt_type == BTINTEL_PCIE_HCI_EVT_PKT)
> - ret = btintel_pcie_recv_event(hdev, new_skb);
> + ret = btintel_pcie_recv_event(hdev, skb);
> else
> - ret = hci_recv_frame(hdev, new_skb);
> + ret = hci_recv_frame(hdev, skb);
> + skb = NULL; /* skb is freed in the callee */
>
> exit_error:
> + if (skb)
> + kfree_skb(skb);
> +
> if (ret)
> hdev->stat.err_rx++;
>
> @@ -1192,8 +1189,6 @@ static void btintel_pcie_rx_work(struct work_struct *work)
> struct btintel_pcie_data *data = container_of(work,
> struct btintel_pcie_data, rx_work);
> struct sk_buff *skb;
> - int err;
> - struct hci_dev *hdev = data->hdev;
>
> if (test_bit(BTINTEL_PCIE_HWEXP_INPROGRESS, &data->flags)) {
> /* Unlike usb products, controller will not send hardware
> @@ -1214,11 +1209,7 @@ static void btintel_pcie_rx_work(struct work_struct *work)
>
> /* Process the sk_buf in queue and send to the HCI layer */
> while ((skb = skb_dequeue(&data->rx_skb_q))) {
> - err = btintel_pcie_recv_frame(data, skb);
> - if (err)
> - bt_dev_err(hdev, "Failed to send received frame: %d",
> - err);
> - kfree_skb(skb);
> + btintel_pcie_recv_frame(data, skb);
> }
> }
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation
2025-04-17 3:48 [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation Kiran K
2025-04-17 4:38 ` [v2] " bluez.test.bot
2025-04-17 5:04 ` [PATCH v2] " Paul Menzel
@ 2025-04-18 14:00 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-04-18 14:00 UTC (permalink / raw)
To: Kiran K
Cc: linux-bluetooth, ravishankar.srivatsa, chethan.tumkur.narayan,
chandrashekar.devegowda, vijay.satija
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 17 Apr 2025 09:18:42 +0530 you wrote:
> Reuse the skb buffer provided by the PCIe driver to pass it onto the
> stack, instead of copying it to a new skb.
>
> Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
> Signed-off-by: Kiran K <kiran.k@intel.com>
> ---
> drivers/bluetooth/btintel_pcie.c | 33 ++++++++++++--------------------
> 1 file changed, 12 insertions(+), 21 deletions(-)
Here is the summary with links:
- [v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation
https://git.kernel.org/bluetooth/bluetooth-next/c/16b4f97defef
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-18 14:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 3:48 [PATCH v2] Bluetooth: btintel_pcie: Avoid redundant buffer allocation Kiran K
2025-04-17 4:38 ` [v2] " bluez.test.bot
2025-04-17 5:04 ` [PATCH v2] " Paul Menzel
2025-04-18 14:00 ` patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox