All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: mirsad.todorovac@alu.unizg.hr
Cc: hkallweit1@gmail.com, linux-kernel@vger.kernel.org,
	Akira Yokosawa <akiyks@gmail.com>
Subject: Re: [PATCH v5 6/7] r8169: Coalesce mac ocp write and modify for 8125 and 8125B start to reduce spinlocks
Date: Tue, 31 Oct 2023 17:23:53 +0900	[thread overview]
Message-ID: <11941121-205b-44fd-86ee-1b86a52a3211@gmail.com> (raw)
In-Reply-To: <e9cb3842-3492-4b85-b7ad-77605a5836c3@alu.unizg.hr>

Hello Mirsad,

[most CCs dropped]

I'm responding to your comment quoted below.  It caught eyes of me
who happens to be a reviewer of LKMM and a LaTeX advisor to perfbook.

On Mon, 30 Oct 2023 16:02:28 +0100, Mirsad Todorovac wrote:
> On 10/30/23 15:02, Heiner Kallweit wrote:
[...]
>> 
>> All this manual locking and unlocking makes the code harder
>> to read and more error-prone. Maybe, as a rule of thumb:
>> If you can replace a block with more than 10 mac ocp ops,
>> then fine with me
> As I worked with another German developer, Mr. Frank Heckenbach from the GNU Pascal project,
> I know that Germans are pedantic and reliable :-)
> 
> If this rtl_hw_start_8125_common() is called only once, then maybe every memory bus cycle
> isn't worth saving, and then maybe the additional complexity isn't worth adding (but it
> was fun doing, and it works with my NIC).
> 
> AFAIK, a spin_lock_irqsave()/spin_unlock_irqrestore() isn't a free lunch as you know, and I read
> from the manuals that on modern CPUs a locked ADD $0, -128(%esp) or something takes about 50
> clock cycles, in which all cores have to wait.

Do you mean, while one of x86 CPUs is executing "lock; addl $0, -4(%esp)"
aka smp_mb(), bus locking prevents all the other CPUs in the system
connected to the bus from doing any memory accesses ???

If it is the case, I believe you are missing the state of the art
optimization of x86 memory system architecture, where most of atomic
operations are done using cache locking.  Bus locking is used only
when it is unavoidable.

Hint: A short introduction can be found at stackoverflow.com [1].
Quote of (then) section 7.1.4 from Intel's SDM vol 3A in the answer
should suffice.

[1]: https://stackoverflow.com/questions/3339141/x86-lock-question-on-multi-core-cpus

A reachable link to Intel SDM should be somewhere in perfbook's bibliography.
The relevant section in Vol 3A is now "2.8.5 Controlling the Processor".

Hope this helps,
Akira

> 
> Doing that in storm of 10 lock/unlock pairs amounts to 500 cycles or 125 ns in the best case
> on a 4 GHz CPU.
> 
> But I trust that you as the maintainer have the big picture and greater insight in the actual hw.



  parent reply	other threads:[~2023-10-31  8:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29 18:35 [PATCH v5 1/7] r8169: Add r8169_mac_ocp_(write|modify)_seq helpers to reduce spinlock contention Mirsad Goran Todorovac
2023-10-29 18:35 ` [PATCH v5 2/7] r8169: Coalesce RTL8411b PHY power-down recovery calls " Mirsad Goran Todorovac
2023-10-30 13:48   ` Heiner Kallweit
2023-10-29 18:35 ` [PATCH v5 3/7] r8169: Coalesce mac ocp write and modify for 8168H start " Mirsad Goran Todorovac
2023-10-30 13:50   ` Heiner Kallweit
2023-10-29 18:36 ` [PATCH v5 4/7] r8169: Coalesce mac ocp write and modify for 8168ep " Mirsad Goran Todorovac
2023-10-30 13:51   ` Heiner Kallweit
2023-10-29 18:36 ` [PATCH v5 5/7] r8169: Reduce spinlock contention for the start of RTL8117 Mirsad Goran Todorovac
2023-10-30 13:51   ` Heiner Kallweit
2023-10-29 18:36 ` [PATCH v5 6/7] r8169: Coalesce mac ocp write and modify for 8125 and 8125B start to reduce spinlocks Mirsad Goran Todorovac
2023-10-30 14:02   ` Heiner Kallweit
2023-10-30 15:02     ` Mirsad Todorovac
2023-10-30 15:53       ` Heiner Kallweit
2023-10-31  8:23       ` Akira Yokosawa [this message]
2023-10-31 13:39         ` Mirsad Todorovac
2023-11-26  1:42         ` Mirsad Todorovac
2023-10-29 18:36 ` [PATCH v5 7/7] r8169: Coalesce mac ocp write and modify for rtl_hw_init_8125 to reduce spinlock contention Mirsad Goran Todorovac
2023-10-30 14:03   ` Heiner Kallweit
2023-10-30 13:39 ` [PATCH v5 1/7] r8169: Add r8169_mac_ocp_(write|modify)_seq helpers " Heiner Kallweit

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=11941121-205b-44fd-86ee-1b86a52a3211@gmail.com \
    --to=akiyks@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirsad.todorovac@alu.unizg.hr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.