linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Alex Kogan <alex.kogan@oracle.com>
Cc: linux-arch@vger.kernel.org, Hanjun Guo <guohanjun@huawei.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Peter Zijlstra <peterz@infradead.org>,
	dave.dice@oracle.com, Jan Glauber <jglauber@marvell.com>,
	x86@kernel.org, Will Deacon <will.deacon@arm.com>,
	linux@armlinux.org.uk, linux-kernel@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	hpa@zytor.com, Steven Sistare <steven.sistare@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v8 4/5] locking/qspinlock: Introduce starvation avoidance into CNA
Date: Fri, 24 Jan 2020 19:38:50 -0500	[thread overview]
Message-ID: <518185c1-c03a-7e8c-9d09-f67e42c9bc82@redhat.com> (raw)
In-Reply-To: <D39064BF-6EF3-4C13-B2D1-34C282A20F5E@oracle.com>

On 1/24/20 4:27 PM, Alex Kogan wrote:
>
>> On Jan 24, 2020, at 4:12 PM, Waiman Long <longman@redhat.com> wrote:
>>
>> On 1/24/20 3:09 PM, Alex Kogan wrote:
>>>>> We also probably do not want those “prioritized” threads to disrupt
>>>>> normal
>>>>> CNA operation. E.g., if the main queue looks like T1_1, P2_1, T1_2,
>>>>> …, where
>>>>> T1_x is a thread running on node 1 and P2_1 is a prioritized thread
>>>>> running
>>>>> on node 2, we want to pass the lock from T1_1 to P2_1 and then to T1_2
>>>>> (rather than have P2_1 to scan for another thread on node 2).
>>>>>
>>>>> There is a way to achieve that — when we pass the lock to P2_1,
>>>>> we can set its numa node field to 1. This means that we need to
>>>>> reset the numa
>>>>> node field in cna_init_node(), but AFAICT this is relatively cheap.
>>>>> The rest
>>>>> of the CNA logic should not change.
>>>> I won't recommend doing that. If the lock cacheline has been moved
>>>> from node 1 to 2, I will say it is better to stick with node 2 rather
>>>> than switching back to node 1. That will mean that the secondary
>>>> queue may contain lock waiters from the same nodes, but they will
>>>> eventually be flushed back to the primary queue.
>>>>
>>> That’s right, assuming we do not reset intra_node count when
>>> transferring the
>>> lock to a prioritized thread from another node. Otherwise, we may starve
>>> waiters in the secondary queue. 
>>>
>>> Still, that can make the lock even less fair to non-prioritized
>>> threads. When
>>> you flush the secondary queue, the preference may remain with the same
>>> node. This will not happen in the current form of CNA, as we never get 
>>> threads from the preferred node in the secondary queue.
>> That is true.
>>
>> However, it is no different from the current scheme that a waiter from
>> another node may have to wait for 64k other waiters to go first before
>> it has a chance to get it. Now that waiter can be from the same node as
>> well.
> The difference is that in the current form of CNA, the preferred node _will
> change after 64k lock transitions. In the change you propose, this is no
> longer the case. It may take another ~64k transitions for that to happen.
> More generally, I think this makes the analysis of the lock behavior more
> convoluted.
>
> I think we should treat those prioritized threads as “wild” cards, passing the 
> lock through them, but keeping the preferred node intact. This will potentially
> cost one extra lock migration, but will make reasoning about the lock
> behavior easier.

It seems like you prefer mathematical purity than practical
consideration. I won't object to that if you insist that is the right
way to go. Just be mindful that you may need to add a preferred node
value to do that. It will also complicate the code, but it is your choice.

Cheers,
Longman


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-01-25  0:39 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 19:40 [PATCH v8 0/5] Add NUMA-awareness to qspinlock Alex Kogan
2019-12-30 19:40 ` [PATCH v8 1/5] locking/qspinlock: Rename mcs lock/unlock macros and make them more generic Alex Kogan
2019-12-30 19:40 ` [PATCH v8 2/5] locking/qspinlock: Refactor the qspinlock slow path Alex Kogan
2019-12-30 19:40 ` [PATCH v8 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock Alex Kogan
2020-01-03 22:14   ` Waiman Long
2020-01-06 15:02     ` Alex Kogan
2020-01-21 13:48   ` Peter Zijlstra
2020-01-21 14:42   ` Peter Zijlstra
2019-12-30 19:40 ` [PATCH v8 4/5] locking/qspinlock: Introduce starvation avoidance into CNA Alex Kogan
2020-01-06 15:33   ` Waiman Long
2020-01-21 13:29   ` Peter Zijlstra
2020-01-21 13:50     ` Peter Zijlstra
2020-01-21 21:19       ` Daniel Bristot de Oliveira
2020-01-21 15:45     ` Waiman Long
     [not found]       ` <3862F8A1-FF9B-40AD-A88E-2C0BA7AF6F58@oracle.com>
2020-01-24  7:52         ` Peter Zijlstra
2020-01-24 14:42           ` Waiman Long
2020-01-24 15:13             ` Peter Zijlstra
2020-01-24 15:19             ` Waiman Long
     [not found]               ` <8D3AFB47-B595-418C-9568-08780DDC58FF@oracle.com>
     [not found]                 ` <714892cd-d96f-4d41-ae8b-d7b7642a6e3c@redhat.com>
2020-01-25 11:16                   ` Peter Zijlstra
     [not found]                   ` <1669BFDE-A1A5-4ED8-B586-035460BBF68A@oracle.com>
     [not found]                     ` <45660873-731a-a810-8c57-1a5a19d266b4@redhat.com>
2020-01-24 18:51                       ` Waiman Long
2020-01-25 11:20                         ` Peter Zijlstra
2020-01-25 19:57                         ` Waiman Long
     [not found]                       ` <693E6287-E37C-4C5D-BE33-B3D813BE505D@oracle.com>
2020-01-24 21:12                         ` Waiman Long
2020-01-24 21:27                           ` Alex Kogan
2020-01-25  0:38                             ` Waiman Long [this message]
2020-01-25 11:19                     ` Peter Zijlstra
2020-01-30 22:05                       ` Alex Kogan
2020-02-03 13:45                         ` Peter Zijlstra
2020-02-03 14:59                           ` Waiman Long
2020-02-03 15:28                             ` Peter Zijlstra
2020-02-03 15:47                               ` Waiman Long
     [not found]                                 ` <83762715-F68C-42DF-9B41-C4C48DF6762F@oracle.com>
2020-02-04 17:27                                   ` Peter Zijlstra
2020-02-04 17:39                                     ` Waiman Long
2020-02-04 17:53                                       ` Alex Kogan
2019-12-30 19:40 ` [PATCH v8 5/5] locking/qspinlock: Introduce the shuffle reduction optimization " Alex Kogan
2020-01-22  9:56   ` Peter Zijlstra
2020-01-06 15:48 ` [PATCH v8 0/5] Add NUMA-awareness to qspinlock Waiman Long
2020-01-08  5:09 ` Shijith Thotton
2020-01-21  9:21   ` Shijith Thotton

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=518185c1-c03a-7e8c-9d09-f67e42c9bc82@redhat.com \
    --to=longman@redhat.com \
    --cc=alex.kogan@oracle.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=daniel.m.jordan@oracle.com \
    --cc=dave.dice@oracle.com \
    --cc=guohanjun@huawei.com \
    --cc=hpa@zytor.com \
    --cc=jglauber@marvell.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=steven.sistare@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).