Message ID | 20220302022755.3876705-2-wangyufen@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf, sockmap: Fix memleaks and issues of mem charge/uncharge | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | success | PR summary |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 76 this patch: 76 |
netdev/cc_maintainers | success | CCed 12 of 12 maintainers |
netdev/build_clang | success | Errors and warnings before: 22 this patch: 22 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 81 this patch: 81 |
netdev/checkpatch | warning | CHECK: Unbalanced braces around else statement |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
bpf/vmtest-bpf-next | success | VM_Test |
On Wed, Mar 02, 2022 at 10:27:52AM +0800, Wang Yufen wrote: > diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h > index fdb5375f0562..c5a2d6f50f25 100644 > --- a/include/linux/skmsg.h > +++ b/include/linux/skmsg.h > @@ -304,21 +304,16 @@ static inline void sock_drop(struct sock *sk, struct sk_buff *skb) > kfree_skb(skb); > } > > -static inline void drop_sk_msg(struct sk_psock *psock, struct sk_msg *msg) > -{ > - if (msg->skb) > - sock_drop(psock->sk, msg->skb); > - kfree(msg); > -} > - > static inline void sk_psock_queue_msg(struct sk_psock *psock, > struct sk_msg *msg) > { > spin_lock_bh(&psock->ingress_lock); > if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) > list_add_tail(&msg->list, &psock->ingress_msg); > - else > - drop_sk_msg(psock, msg); > + else { > + sk_msg_free(psock->sk, msg); __sk_msg_free() calls sk_msg_init() at the end. > + kfree(msg); Now you free it, hence the above sk_msg_init() is completely unnecessary. Thanks.
在 2022/3/3 8:41, Cong Wang 写道: > On Wed, Mar 02, 2022 at 10:27:52AM +0800, Wang Yufen wrote: >> diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h >> index fdb5375f0562..c5a2d6f50f25 100644 >> --- a/include/linux/skmsg.h >> +++ b/include/linux/skmsg.h >> @@ -304,21 +304,16 @@ static inline void sock_drop(struct sock *sk, struct sk_buff *skb) >> kfree_skb(skb); >> } >> >> -static inline void drop_sk_msg(struct sk_psock *psock, struct sk_msg *msg) >> -{ >> - if (msg->skb) >> - sock_drop(psock->sk, msg->skb); >> - kfree(msg); >> -} >> - >> static inline void sk_psock_queue_msg(struct sk_psock *psock, >> struct sk_msg *msg) >> { >> spin_lock_bh(&psock->ingress_lock); >> if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) >> list_add_tail(&msg->list, &psock->ingress_msg); >> - else >> - drop_sk_msg(psock, msg); >> + else { >> + sk_msg_free(psock->sk, msg); > __sk_msg_free() calls sk_msg_init() at the end. > >> + kfree(msg); > Now you free it, hence the above sk_msg_init() is completely > unnecessary. Invoking of sk_msg_free() does not always follow kfree(). That is, sk_msg needs to be reused in some cases. We can implement sk_msg_free_xx() without sk_msg_init(), but I don't think it is necessary. Thanks > > Thanks. > .
diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index fdb5375f0562..c5a2d6f50f25 100644 --- a/include/linux/skmsg.h +++ b/include/linux/skmsg.h @@ -304,21 +304,16 @@ static inline void sock_drop(struct sock *sk, struct sk_buff *skb) kfree_skb(skb); } -static inline void drop_sk_msg(struct sk_psock *psock, struct sk_msg *msg) -{ - if (msg->skb) - sock_drop(psock->sk, msg->skb); - kfree(msg); -} - static inline void sk_psock_queue_msg(struct sk_psock *psock, struct sk_msg *msg) { spin_lock_bh(&psock->ingress_lock); if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) list_add_tail(&msg->list, &psock->ingress_msg); - else - drop_sk_msg(psock, msg); + else { + sk_msg_free(psock->sk, msg); + kfree(msg); + } spin_unlock_bh(&psock->ingress_lock); }