mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Yonglong Li <liyonglong@chinatelecom.cn>,
	mptcp@lists.linux.dev,  Paolo Abeni <pabeni@redhat.com>
Subject: Re: [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other"
Date: Mon, 12 Jul 2021 15:27:11 -0700 (PDT)	[thread overview]
Message-ID: <6ddf9ad-6ef-c1b-7d90-375ddc3e0e2@linux.intel.com> (raw)
In-Reply-To: <CA+WQbwuTi7iqN-2=b0kehULSABvVJ_ayS-w+ahbBPQq8i7mGgg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2499 bytes --]

On Mon, 12 Jul 2021, Geliang Tang wrote:

> Yonglong Li <liyonglong@chinatelecom.cn> 于2021年7月12日周一 下午5:55写道:
>>
>>
>>
>> On 2021/7/11 23:15, Geliang Tang wrote:
>>> Add READ_ONCE() for reading msk->pm.addr_signal.
>>>
>>> Use mptcp_pm_should_add_signal_echo instead of open coding.
>>>
>>> Use '&=' to clear flag.
>>>
>>> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
>>> ---
>>>  net/mptcp/pm.c | 12 ++++++++----
>>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
>>> index c9622696716e..be16da2dcb6b 100644
>>> --- a/net/mptcp/pm.c
>>> +++ b/net/mptcp/pm.c
>>> @@ -257,6 +257,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>>>                             struct mptcp_addr_info *saddr, bool *echo, bool *port)
>>>  {
>>>       int ret = false;
>>> +     u8 add_addr;
>>>
>>>       spin_lock_bh(&msk->pm.lock);
>>>
>>> @@ -271,10 +272,12 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>>>               goto out_unlock;
>>>
>>>       *saddr = msk->pm.local;
>>> -     if ((msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_ECHO)))
>>> -             WRITE_ONCE(msk->pm.addr_signal, msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_ECHO));
>>> +     add_addr = READ_ONCE(msk->pm.addr_signal);

Like below, pm.lock is held here so READ_ONCE() isn't needed.

>>> +     if (mptcp_pm_should_add_signal_echo(msk))
>>> +             add_addr &= ~BIT(MPTCP_ADD_ADDR_ECHO);
>>>       else
>>> -             WRITE_ONCE(msk->pm.addr_signal, msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_SIGNAL));
>>> +             add_addr &= ~BIT(MPTCP_ADD_ADDR_SIGNAL);
>>> +     WRITE_ONCE(msk->pm.addr_signal, add_addr);
>>>       ret = true;
>>>
>>>  out_unlock:
>>> @@ -294,7 +297,8 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>>>       if (!mptcp_pm_should_rm_signal(msk))
>>>               goto out_unlock;
>>>
>>> -     rm_addr = msk->pm.addr_signal & ~BIT(MPTCP_RM_ADDR_SIGNAL);
>>> +     rm_addr = READ_ONCE(msk->pm.addr_signal);
>>> +     rm_addr &= ~BIT(MPTCP_RM_ADDR_SIGNAL);
>>>       len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
>>>       if (len < 0) {
>>>               WRITE_ONCE(msk->pm.addr_signal, rm_addr);
>>>
>>
>> These chunk of code is under the pm.lock so It is no need to use READ_ONCE() as Paolo saied before.
>
> I'll drop this READ_ONCE() in v2.
>
>>
>> --
>> Li YongLong
>
>

--
Mat Martineau
Intel

  reply	other threads:[~2021-07-12 22:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11 15:15 [MPTCP][PATCH mptcp-next] Squash to "mptcp: make MPTCP_ADD_ADDR_SIGNAL and MPTCP_ADD_ADDR_ECHO separate" Geliang Tang
2021-07-11 15:15 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other" Geliang Tang
2021-07-12  9:55   ` Yonglong Li
2021-07-12 10:34     ` Geliang Tang
2021-07-12 22:27       ` Mat Martineau [this message]
2021-07-11 15:15 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: build ADD_ADDR/echo-ADD_ADDR option according pm.add_signal" Geliang Tang
2021-07-12  1:34   ` Yonglong Li
2021-07-12  7:33     ` Geliang Tang
2021-07-12  8:06       ` Yonglong Li
2021-07-12  8:44         ` Geliang Tang
2021-07-12  9:07           ` Geliang Tang
2021-07-12  9:21             ` Yonglong Li
2021-07-12  9:14           ` Yonglong Li
2021-07-12  9:29             ` Geliang Tang
2021-07-12  9:44               ` Yonglong Li
2021-07-12 10:34                 ` Geliang Tang
2021-07-12 22:10 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: make MPTCP_ADD_ADDR_SIGNAL and MPTCP_ADD_ADDR_ECHO separate" Mat Martineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ddf9ad-6ef-c1b-7d90-375ddc3e0e2@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=geliangtang@gmail.com \
    --cc=liyonglong@chinatelecom.cn \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --subject='Re: [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other"' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).