Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp592659imp; Wed, 20 Feb 2019 05:45:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYrw6su4ehHXHX6KVfOal1zNA0FEsjcW44HdyMeD5ZVdVMSJBFu9tbAVR1ZOS38FcU8LYzN X-Received: by 2002:a17:902:b287:: with SMTP id u7mr27995032plr.69.1550670352094; Wed, 20 Feb 2019 05:45:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550670352; cv=none; d=google.com; s=arc-20160816; b=KitGpGiCPCFQ3vD9fwbfZCPSpnxa8ACQJ0WW/b1fhlq7+Rqjzfrg5UeNh73YGv8y/y PkarZphGnRJIZrNAJ8V7s35Zvr9Me4K8rl9F4fZREMhQp3XY2eBAAdlMKvXkoErNn5cj Mt6r1/puk1R9BaN85M7Vwf2Xfd6cac+FPgf0h1Qyqkz0AloZFbwJppj6/ZWjtkB/fVJK 0nHXBUyXsZt/b9j9Th3JNP0Lc5g8gff6mDpOlHQLcALPQG1hhSewFEyB+k1YUFayjoTd RTNtezMX+Mw5LoX6lWS7S7dRgdOIwF23sH1FAtqM6IPCv3oufSVZwq/42spuzBs49FMv OE6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1FaPtUN6X+te83Y4+p98tzajqlQXdAj23kTLzAX63ks=; b=IlbIFsV91D6AG5O/NudPCQIYlftRxoZGqHhNqAmtQB641EcWfhqWq0oqpfaBDgO+Te qIlScXjQFYQ7SwiL+G5wSFbpV3m0hXMxf8bBILQl4gPPmEw/+fP9g0Ev6UNadnmWZWU+ yif+RopV4nPzYNsW2NWNHUUFo+wgoV9SDtPC0c8bjPbHwU36yOnC2WbdPmMIeIEPZhkI RHmadic+Ss0f5EdSyHftAAP+rvQ2irKwU9Luk04L+5NmFWIkxwWvbXYYU4DZi1st/fmW pUWk6IkhhTDn515dQWfbrqKAPKLOBFoRcmbR3ZBDxXKztwD7PxJ6th/4h31LVYB1u6PO D6pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aEhSAnK2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si10777242plk.85.2019.02.20.05.45.35; Wed, 20 Feb 2019 05:45:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aEhSAnK2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725883AbfBTNot (ORCPT + 99 others); Wed, 20 Feb 2019 08:44:49 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52137 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbfBTNot (ORCPT ); Wed, 20 Feb 2019 08:44:49 -0500 Received: by mail-wm1-f65.google.com with SMTP id n19so6673729wmi.1 for ; Wed, 20 Feb 2019 05:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1FaPtUN6X+te83Y4+p98tzajqlQXdAj23kTLzAX63ks=; b=aEhSAnK2erJmewTp6jhY5vt3e1otxe+TDSaednmw+wKbWFU6CSCseVZiUZStaT05wQ INjei/6byZ4kktPiXIQAMYJjO2Pg3VA3v8jYiym3ONacJ/wQmldLb6D6G3qk/mx7UG5l Ji5qzk28Ii4g2ZNN3ZcL9sNmc8C6QEi7J4/3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1FaPtUN6X+te83Y4+p98tzajqlQXdAj23kTLzAX63ks=; b=aOgbJ4TXHAvHJ8cpFJ4+wI7bU384OILUCcbx3GynlYnT4nn4oSO7LndKKb6BXV4qKM l+ALdMaLtLOAQLVh203y8DyiNYrHsKSnVNSqsfm36xZXSFFTlxTQhrEJhyN4XF7c2N35 5U/3uQ7mLh5cgwSL8RevAkoyQFvkAQH1YKIk4igpylDVjq061/JKuhnmU/JPdYXmSW9y jYSOAhV97TKg9L0+uI1J31amkTgIOI6rABIMjpG46GCDaobQRqWdwASGAuu3WGMfRI8Y KPmoir2aHcSlIiol8Cy6vQ3s6I9fsu8minFjJX18fIdyJVAR6geU/qTOAeV0gUIXmcbX dHTw== X-Gm-Message-State: AHQUAuZyVFYlrkZWYFrimTT3TJE2cKXS7MNscTdp70AtN3rcBXm5aRfx cyi95+ShxDam3vBtrrcOl2ZL4Q== X-Received: by 2002:a7b:c3c3:: with SMTP id t3mr6823987wmj.120.1550670286974; Wed, 20 Feb 2019 05:44:46 -0800 (PST) Received: from andrea ([89.22.71.151]) by smtp.gmail.com with ESMTPSA id f4sm13179422wrx.68.2019.02.20.05.44.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 05:44:45 -0800 (PST) Date: Wed, 20 Feb 2019 14:44:33 +0100 From: Andrea Parri To: Michael Ellerman Cc: Petr Mladek , linuxppc-dev@ozlabs.org, akpm@linux-foundation.org, tj@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, dyoung@redhat.com, sergey.senozhatsky@gmail.com, Steven Rostedt Subject: Re: [PATCH v3 1/7] dump_stack: Support adding to the dump stack arch description Message-ID: <20190220134433.GA4932@andrea> References: <20190207124635.3885-1-mpe@ellerman.id.au> <20190211125035.GA1562@andrea> <20190211143859.dd2lkccxod3f2fwn@pathway.suse.cz> <20190219233925.GA5648@andrea> <87va1e7pw2.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87va1e7pw2.fsf@concordia.ellerman.id.au> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> > > + * Order the stores above in vsnprintf() vs the store of the > >> > > + * space below which joins the two strings. Note this doesn't > >> > > + * make the code truly race free because there is no barrier on > >> > > + * the read side. ie. Another CPU might load the uninitialised > >> > > + * tail of the buffer first and then the space below (rather > >> > > + * than the NULL that was there previously), and so print the > >> > > + * uninitialised tail. But the whole string lives in BSS so in > >> > > + * practice it should just see NULLs. > >> > > >> > The comment doesn't say _why_ we need to order these stores: IOW, what > >> > will or can go wrong without this order? This isn't clear to me. > >> > > >> > Another good practice when adding smp_*-constructs (as discussed, e.g., > >> > at KS'18) is to indicate the matching construct/synch. mechanism. > >> > >> Yes, one barrier without a counter-part is suspicious. > > > > As is this silence..., > > > > Michael, what happened to this patch? did you submit a new version? > > No, I'm just busy, it's the merge window next week :) Got it. > > I thought the comment was pretty clear, if the stores are observed out > of order we might print the uninitialised tail. > > And the barrier on the read side would need to be in printk somewhere, > which is obviously unpleasant. Indeed. > > >> If the parallel access is really needed then we could define the > >> current length as atomic_t and use: > >> > >> + atomic_cmpxchg() to reserve the space for the string > >> + %*s to limit the printed length > >> > >> In the worst case, we would print an incomplete string. > >> See below for a sample code. > > > > Seems worth exploring, IMO; but I'd like to first hear _clear about > > the _intended semantics (before digging into alternatives)... > > It is not my intention to support concurrent updates of the string. The > idea is you setup the string early in boot. Understood, thanks for the clarification. > > The concern with a concurrent reader is simply that the string is dumped > in the panic path, and you never really know when you're going to panic. > Even if you only write to the string before doing SMP bringup you might > still have another CPU go rogue and panic before then. > > But I probably should have just not added the barrier, it's over > paranoid and will almost certainly never matter in practice. Oh, well, I can only echo you: if you don't care about the stores being _observed_ out of order, you could simply remove the barrier; if you do care, then you need "more paranoid" on the readers side. ;-) Andrea > > cheers