Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp934263pxb; Thu, 28 Jan 2021 04:11:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEadJMtzGlzRLmwVRql1sr6OlYvKxLHxg38jP/7LOgquUsSqmd726wwOAIWyUz3apsI9tB X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr10809475eje.109.1611835913637; Thu, 28 Jan 2021 04:11:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611835913; cv=pass; d=google.com; s=arc-20160816; b=UbnIABkL0RkKSfgBKolRnv/QS56m265VW0iI7+rAW+8vHzrrD5qDpu0Z6xx6c/hcnG 7qHUYJ7C8OAbun9OYoYlL+IEPqPx9N4OX2NJwVTu8r1v+7d8cDTi3FDTojr2yn2Qwbep Il6wkiYsIM3lwVr7P32+aHnyNnu470b51u0mZKm0NOtKN2t9h97Rg4QYPUNgKWmyQyMi LZ3ZvSlXl8fsnPXiAKNhLomVH51DlcnrYyUhzBLrheyTDs4MiFMEir1zUueMPB7WIbuA Zjz8A7frYmjgxqYEwC/2DEwMRpA6HPMKa2XlBNU2q7S4qc1gYdagmuMc0ef0lya12L0E D/pQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=ZO9z5G/GuaoXIA6nSx8XgTqSNFDo5kkVO5YgyaiCM04=; b=TwlgFNGzk7aLNl8nPLRjMmMhJe+Ox917HOqd30eZohR1taN/JlLGhKb6s3IhtMHY9g mae1TMJpxggTLqNqGDjAWX2kHffN7hDTZo57u1L0LoFGz868YnoyAQm0DwCoXQh1Ji5U x1L9wNh25SlZtzyBTuXXlDV3taXzm1HLFHLZ8ZoICNyg9INO8icsDB4FnFpqTbCHWUPl 2eDxtLACSclmWaqkhSaKlcon20kF/ujTGlr0mvJEEwc5+uvWv7YFVf8WzO4rQ97ghuOR 3nplZlabZbwrohFYWxgr2LPSztoGv2kskxz++VoGSFkk1NcY9Ji6wVGu+tcP+4tRW650 Ub4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=ckccAzoX; arc=pass (i=1 spf=pass spfdomain=nokia.com dkim=pass dkdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si2450710ejr.25.2021.01.28.04.11.28; Thu, 28 Jan 2021 04:11:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=ckccAzoX; arc=pass (i=1 spf=pass spfdomain=nokia.com dkim=pass dkdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbhA1MKe (ORCPT + 99 others); Thu, 28 Jan 2021 07:10:34 -0500 Received: from mail-eopbgr30136.outbound.protection.outlook.com ([40.107.3.136]:28577 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229817AbhA1MKa (ORCPT ); Thu, 28 Jan 2021 07:10:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PpT1IzfNJuIYFNoZ3CeuZENx+1qzbuTtYsjBmtP0oi5cpQEUkKcd4YaQ0NGIY+bRIgW1T/EOMlfC7pmr9l5XNQ39XQFiAjAeTdLIHTgWNybEcMOBXcUwJNBO1mdCSH+ZsNgclW/iw5GGf9EH0FyRkcz4c+PWBOK3eAG5V+m7l1zPGTp2YpM9kXntJPBRLBHFHUOIu637WC2qiCtWUUVwTiDxLINWKVWce/kwjsmwJ7EtJKl7E6t7+ggWgR2hiCqRLdwFRjT/cLIUYmXJjDl3Gl13XzmO1xpqRfUqVJ7njf18++GSb2kasG81dQ0YmDvJYwA+eh8gQOeiuNJnQAwALg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZO9z5G/GuaoXIA6nSx8XgTqSNFDo5kkVO5YgyaiCM04=; b=If38DSwDGE1OabxziKhk3fHG77s2HCsq2zVlHUNLw3TiG1bPXdEdsqCH99xxQHSG4Cytkio6kTFdWDhDSPQOzGYC8rg7ks+xdlqrUsqzehv5IFCcWHKTOz2L9T2CvDcxmIVTuDrLbBOZdlMu7xWq9pkNO1EJ+TAGxxHprFeI2LwZoo7fu3xfLs8HIgAVp7VFPswp0vyUhAAlXgiWaabDuFnrzTqhAn1rqbnFuzciBF6PykPMxggETKCZwjNEU4z/h3nNdtpyFWFyazascCFlVjnLv114q9sdF2y1ME3C/8sX6Eotvi2p0x93UAn2VWxMYAqs9Ijf5HIKJj6zmLPDkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZO9z5G/GuaoXIA6nSx8XgTqSNFDo5kkVO5YgyaiCM04=; b=ckccAzoX1Z6Xc069CTq8I2EGJnwf6hnpWHu0bZnqDUD57odw11vExtkglX2OPnPEiODc45u10oTXBTDJ8TdXKj52bALnlQOg7jrtJIj9NpXpo5vdBvqyR5uahYYvT235RAaqd8Dpyx0VWxVgcNXjq2OQWITxhmzlvESRBXrKESU= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nokia.com; Received: from (2603:10a6:208:6e::15) by AM0PR07MB4033.eurprd07.prod.outlook.com (2603:10a6:208:3f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.6; Thu, 28 Jan 2021 12:09:42 +0000 Received: from AM0PR07MB4531.eurprd07.prod.outlook.com ([fe80::e965:2884:260b:b29a]) by AM0PR07MB4531.eurprd07.prod.outlook.com ([fe80::e965:2884:260b:b29a%3]) with mapi id 15.20.3825.008; Thu, 28 Jan 2021 12:09:42 +0000 Subject: Re: [PATCH 1/6] MIPS: Octeon: Implement __smp_store_release() To: Peter Zijlstra Cc: Paul Burton , linux-mips@vger.kernel.org, Thomas Bogendoerfer , Will Deacon , Boqun Feng , Ingo Molnar , linux-kernel@vger.kernel.org References: <20210127203627.47510-1-alexander.sverdlin@nokia.com> <20210127203627.47510-2-alexander.sverdlin@nokia.com> From: Alexander Sverdlin Message-ID: <3c0165d9-1814-df1d-7ec9-bf515a3996b3@nokia.com> Date: Thu, 28 Jan 2021 13:09:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [131.228.32.168] X-ClientProxiedBy: AM0P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::39) To AM0PR07MB4531.eurprd07.prod.outlook.com (2603:10a6:208:6e::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ulegcpsvhp1.emea.nsn-net.net (131.228.32.168) by AM0P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16 via Frontend Transport; Thu, 28 Jan 2021 12:09:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 01c6ded0-f484-4d03-e821-08d8c38597ee X-MS-TrafficTypeDiagnostic: AM0PR07MB4033: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:446; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L1c2XhArCsXn/0zbQwga6kaf3FS/obzXHR1+yvhrMChuRtmNyUlowvLqKaJGKDehG40q+AQazoc5rGevEUClZxx8aKH9KtzOazN546JSiAECzQJ7+Ck2ZNfV925BYrGpecUxlsaDDKUO9RaNvvbu94vLZswM+c1QiF80ifPPhU3ti7CL+O2aNA3JOjwLvdIiPavLCWOHsdvrxxEVF7f7SAIveJfVOO6PeJiNynH+8a/lRPKwwLJ7SJtNfqfPxzeNJVwHniOAZcgQDo8Lfp3akRaZopSq4qeN6BEtRYIg5CoGR/GfcQsH4Mdp6+HXE2sW26eiHqqyJJqsiyX6b0eJCPafcq+hGkEmoelsqzjgSjMLX3g8WtR1mIjZI3anMq220CdHHrPZtXizqFIgigVnL004KbpVkKzP10z/KkgTXE7AdHFU0e59ekMAGNH7OYUYX0TNYhGShVeo0lgTW4X/W6NGZD9SkBehJunJzeEJ2J1rUfQe7SalhefwGHw5pmhi1t5jB7/vhBVbqd3ruRZLk/z1NzlglpU2H7O+9P8JnwM6+pJ1zJJrGsRo1mpRjFsWjT6E2UDsHZHJJK03QNVKGrqXv+lF4yncrsBvot3s968y+SeXQzLd6oaXuFqCGgKmLLYAUbCTWH1/+27OZS309ZYE3LpALtj5xq5+lxQ5SHEmRKVfhdoLXJEAAEVrvhO6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR07MB4531.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(396003)(366004)(346002)(136003)(39860400002)(66946007)(4326008)(66574015)(478600001)(186003)(66476007)(66556008)(956004)(316002)(2616005)(86362001)(54906003)(52116002)(2906002)(16526019)(8936002)(44832011)(6486002)(8676002)(31686004)(83380400001)(966005)(26005)(6506007)(53546011)(6512007)(5660300002)(36756003)(6916009)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?K2pQTjc1Qk1rTVA4SXc2Q1JoeUh2TjFPN011V1JLUUI2VGxnR0d3ZVkwcG0z?= =?utf-8?B?azdnUWhwMHdvUGlZd0JwdWZiVnhPbXVPU2kwS0FzaHNpT2ZzUi9kcytWbDZa?= =?utf-8?B?ek5Ub1hHdHRVQVQveVFYR2I4Qjc2em03ZkdTZVhqa1kweGJ5RFE1ZUJuZ3lz?= =?utf-8?B?ZUM4UnNRcDBRV2JJbWY2SUtWU2VYUi9udjd4RVk5V1NtZzBHNTlFNG0xUDZv?= =?utf-8?B?dFpaaW1WLytpVTNkRjVYUzhVcDk1bWR0UXlOaU4vQmNxZk9oeUtwM3VLWG5H?= =?utf-8?B?T0g4blNlQ1ZMUXRJUHYwODliMklvYkpoVW51bnBTakcwYzNmR3Y3VysrYlZQ?= =?utf-8?B?T1JtNksxM1N1RzRyUXEzRnBLS0t5cjdJNDZsSGRyU1c2aW8rMWdDRytCaUVT?= =?utf-8?B?YTB6VUV6ZVNHMU0rcDlEbjN1SVNMQy9mMHdQenlxcHhNVERweTRHSVNWcmFk?= =?utf-8?B?NnRqZmNOS292aGpoWH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VlR?= =?utf-8?B?NS9JMFM0L3prdDZkWlVpa3JGZ2EzV1YrSFRDTjlxN00wMHRBK0Zhazhiam50?= =?utf-8?Q?AInEwA4u?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01c6ded0-f484-4d03-e821-08d8c38597ee X-MS-Exchange-CrossTenant-AuthSource: AM0PR07MB4531.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2021 12:09:42.1407 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tyTtZLB5hR8nT2elAX/6I7nhH6H0q5DczNveF5KhZmxBYPNhUYMOBJArrKlJY3FL2PqTfXHD87iHwv33ECQKfUDBkswvc7JWhbLw3VsvYHM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR07MB4033 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On 28/01/2021 12:33, Peter Zijlstra wrote: > On Thu, Jan 28, 2021 at 08:27:29AM +0100, Alexander Sverdlin wrote: > >>>> +#define __smp_store_release(p, v) \ >>>> +do { \ >>>> + compiletime_assert_atomic_type(*p); \ >>>> + __smp_wmb(); \ >>>> + __smp_rmb(); \ >>>> + WRITE_ONCE(*p, v); \ >>>> +} while (0) >>> This is wrong in general since smp_rmb() will only provide order between >>> two loads and smp_store_release() is a store. >>> >>> If this is correct for all MIPS, this needs a giant comment on exactly >>> how that smp_rmb() makes sense here. >> >> ... the macro is provided for Octeon only, and __smp_rmb() is actually a NOP >> there, but I thought to "document" the flow of thoughts from the discussion >> above by including it anyway. > > Random discussions on the internet do not absolve you from having to > write coherent comments. Especially so where memory ordering is > concerned. I actually hoped you will remember the discussion you've participated 5 years ago and (in my understanding) actually already agreed that the solution itself is not broken: https://lore.kernel.org/lkml/20151112180003.GE17308@twins.programming.kicks-ass.net/ Could you please just suggest the proper comment you expect to be added here, because there is no doubts, you have much more experience here than me? > This, from commit 6b07d38aaa52 ("MIPS: Octeon: Use optimized memory > barrier primitives."): > > #define smp_mb__before_llsc() smp_wmb() > #define __smp_mb__before_llsc() __smp_wmb() > > is also dodgy as hell and really wants a comment too. I'm not buying the > Changelog of that commit either, __smp_mb__before_llsc should also > ensure the LL cannot happen earlier, but SYNCW has no effect on loads. > So what stops the load from being speculated? > > -- Best regards, Alexander Sverdlin.