From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0944C433EF for ; Tue, 10 May 2022 18:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240303AbiEJStH (ORCPT ); Tue, 10 May 2022 14:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349156AbiEJSrJ (ORCPT ); Tue, 10 May 2022 14:47:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E6F1488BF for ; Tue, 10 May 2022 11:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652208426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lDaf3WbpWZER89SWe3+3un2eTu5W4KfGxQhX3Ozl0ck=; b=gj4lhj9EmMcwSE3d9fgxqAbxJTiQGQoYK0znMA7AEc7ojB0iGLj9wlmP513nBOmBkhmoWF rnNz6DWXM/dLv6777YLd7ZYkGKz1LiN7JTB6rhhk4ATnTNXNrYaKZtCmKIl8RsvC6R6rTP fTlkfXXqfBHcjm8LJZ9Kj3/3aLHEyG8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-5-Rr2WiEDLMQCstKY51qfaRw-1; Tue, 10 May 2022 14:47:03 -0400 X-MC-Unique: Rr2WiEDLMQCstKY51qfaRw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9AF8811E7A; Tue, 10 May 2022 18:47:02 +0000 (UTC) Received: from [10.18.17.215] (dhcp-17-215.bos.redhat.com [10.18.17.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33974401E74; Tue, 10 May 2022 18:47:02 +0000 (UTC) Message-ID: <56474c28-e62a-36b1-257b-9e5ffb11b0e2@redhat.com> Date: Tue, 10 May 2022 14:47:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [mm/page_alloc] f26b3fa046: netperf.Throughput_Mbps -18.0% regression Content-Language: en-US To: Linus Torvalds , "ying.huang@intel.com" , Peter Zijlstra , Will Deacon Cc: Aaron Lu , Mel Gorman , kernel test robot , Vlastimil Babka , Dave Hansen , Jesper Dangaard Brouer , Michal Hocko , Andrew Morton , LKML , lkp@lists.01.org, kernel test robot , Feng Tang , Zhengjun Xing , fengwei.yin@intel.com References: <20220420013526.GB14333@xsang-OptiPlex-9020> <7d20a9543f69523cfda280e3f5ab17d68db037ab.camel@intel.com> <37dac785a08e3a341bf05d9ee35f19718ce83d26.camel@intel.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/10/22 14:05, Linus Torvalds wrote: > [ Adding locking people in case they have any input ] > > On Mon, May 9, 2022 at 11:23 PM ying.huang@intel.com > wrote: >>> Can you point me to the regression report? I would like to take a look, >>> thanks. >> https://lore.kernel.org/all/1425108604.10337.84.camel@linux.intel.com/ > Hmm. > > That explanation looks believable, except that our qspinlocks > shouldn't be spinning on the lock itself, but spinning on the mcs node > it inserts into the lock. > > Or so I believed before I looked closer at the code again (it's been years). > > It turns out we spin on the lock itself if we're the "head waiter". So > somebody is always spinning. > > That's a bit unfortunate for this workload, I guess. > > I think from a pure lock standpoint, it's the right thing to do (no > unnecessary bouncing, with the lock releaser doing just one write, and > the head waiter spinning on it is doing the right thing). > > But I think this is an example of where you end up having that > spinning on the lock possibly then being a disturbance on the other > fields around the lock. > > I wonder if Waiman / PeterZ / Will have any comments on that. Maybe > that "spin on the lock itself" is just fundamentally the only correct > thing, but since my initial reaction was "no, we're spinning on the > mcs node", maybe that would be _possible_? > > We do have a lot of those spinlocks embedded in other data structures > cases. And if "somebody else is waiting for the lock" contends badly > with "the lock holder is doing a lot of writes close to the lock", > then that's not great. Qspinlock still has one head waiter spinning on the lock. This is much better than the original ticket spinlock where there will be n waiters spinning on the lock. That is the cost of a cheap unlock. There is no way to eliminate all lock spinning unless we use MCS lock directly which will require a change in locking API as well as more expensive unlock. Cheers, Longman