Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp170353ybg; Mon, 27 Jul 2020 19:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Fo8NeVJ+tgm9Uqg+CM77zHOjEZ5mUTT5rR3feKs5KBT6q1I5T3NX23rpsGROgZfQUo7I X-Received: by 2002:a05:6402:1805:: with SMTP id g5mr23255359edy.357.1595903047440; Mon, 27 Jul 2020 19:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595903047; cv=none; d=google.com; s=arc-20160816; b=MPw0lZwqqGgIfrQspUb7Df/V8Lq4WQw/aQB1kO6UsB0ZUKRE3hAETQcopss5FXjfNy NaiSiZY55+dUeR3DbyJQHVj61jgQPILrPkYOuEIsQiDLQPxYHGL0QQSn8pZZT948jyzr Is7Wg18xAVy3vU6zJqex4QqDZgn97W0vq3JqztOLI8IUigguDLhr06rM3U5CCtF57IQO 5Xvg/XZ1YDWOTXT0mUQnyaS1Dr2LN5Vg3Ki/9AnxuK7X81mMLV0ALKn1/MawkuGV9Ccr B7OEpbfmMW1IZlOZjimeSQUFPlvX+FeYNxyBK2HvlZFFYTMC27fEkp3fxrmi/cQDBU/u GDpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bmpjZY3DS+knka6HwVXGoRUInVOpnqRy9fgTe+9ox3o=; b=lEwhIQqmmFgHO31wjuflBBOdme47R9cmHmciayW8A/XpzZdLkQ8sPf8R2TaYTe5G+I Rt7y1NM58VxDhuV1bpBfCTV0Ns7qUmsVlkZpP9Rxoqzuht4YVsJ5gO7zNFLS1udIkKSy CFyQiPuC2IDDIrGGFFSS2xM4vw7lnhf3hkgxWFMHdqH8lAjZmD9sLeY57u2C27/9ct9A ocmdciYeGHsp9NwlmZY1TmYWvcCYDZFvkDoTOjop+ASZPiYFRuW8xJgTJiKMVU7dZX66 tbA/MxCAVgtOVn3LgV13DZdveHC5m/idGltd5OdV0dqgjW27sAEcHcuFfM5nky/lPbGf 6Lpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A6Q65jzY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc15si6664896ejb.526.2020.07.27.19.23.43; Mon, 27 Jul 2020 19:24:07 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=A6Q65jzY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgG1CXC (ORCPT + 99 others); Mon, 27 Jul 2020 22:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgG1CXC (ORCPT ); Mon, 27 Jul 2020 22:23:02 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA4FC061794 for ; Mon, 27 Jul 2020 19:23:02 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id f9so4513624pju.4 for ; Mon, 27 Jul 2020 19:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bmpjZY3DS+knka6HwVXGoRUInVOpnqRy9fgTe+9ox3o=; b=A6Q65jzY2cfoaTXJphioBYwzUZ+be9yKf0+IeSTMnXUN/l1RxIvIRCe9/LQZBBLDdp heAnKx5XcgEA28i6r52O8AXSsofuVQpw0tkEXqfnj4rR34bc0q5NdPDF+0WRhWnYJzLq jsX4NQItW4WQzrUiEiu9TSVbvO3Z5BecCXbA+9klSWOO127jwaJk7DUsKGF5Twi2orVm mJIazyPyfHUS/91rV8QOmESVm4V1ntZ/3fP72BU/bu4ipr1GnBL1fy64uxY+hoBSG9Fg W+Tci1LwLzwf+XBKoHkqfJeEaruOj3mt3ijECXDKTrLKR5+EaXVzRC/w5QCj0BIk8sD6 rrmw== 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; bh=bmpjZY3DS+knka6HwVXGoRUInVOpnqRy9fgTe+9ox3o=; b=fnfd6jA5tAABsUtaF9ZY9qLXs7phU8bBMzKEXo+FG2cMThjUOJ/rKzdCMpt1lQdprK hzzeLrS1glyquOk96IarHtvwE9PXjITkMYbilCt3XMrAnfJPFUby45szIN9tH9lUvraV DfxtHhOvBPb/Mnvqcp34EAocdJdYimrGtcL4QHXq7tauYJyrfikNuNEgUdY4vrqOQVdq i6Xtg9n4N+EJdboWxGk3NAKARcy6rgCH6Xm16kpM85+ZEB6xSoxMU8jNhWYELcKkcM1b 7MjsmOwV4bekBCDCZHRSAB0xwIWyXoMwgwR1MouyzQAstdn2lKHH3+HjB7qB/S4aRnGA 2cGw== X-Gm-Message-State: AOAM530NMfBbpCaS/wSrM+ObiyOpd6tm4/3JU1sT8mKwDQzIU08I4RyP bAYi95sBoQbtY27U5Oer1dc= X-Received: by 2002:a17:902:ed14:: with SMTP id b20mr22338790pld.25.1595902981696; Mon, 27 Jul 2020 19:23:01 -0700 (PDT) Received: from localhost ([2409:10:2e40:5100:6e29:95ff:fe2d:8f34]) by smtp.gmail.com with ESMTPSA id g28sm16076428pfr.70.2020.07.27.19.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 19:23:00 -0700 (PDT) Date: Tue, 28 Jul 2020 11:22:59 +0900 From: Sergey Senozhatsky To: Linus Torvalds Cc: Sergey Senozhatsky , John Ogness , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Greg Kroah-Hartman , Peter Zijlstra , Thomas Gleixner , kexec@lists.infradead.org, Linux Kernel Mailing List Subject: Re: [PATCH 2/4] printk: store instead of processing cont parts Message-ID: <20200728022259.GB1286082@jagdpanzerIV.localdomain> References: <20200717234818.8622-1-john.ogness@linutronix.de> <20200717234818.8622-3-john.ogness@linutronix.de> <20200719143527.GA566@jagdpanzerIV.localdomain> <20200720015057.GA463@jagdpanzerIV.localdomain> <20200721144220.GE44523@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/07/21 08:40), Linus Torvalds wrote: > On Tue, Jul 21, 2020 at 7:42 AM Sergey Senozhatsky > wrote: > > > > OK, so basically, extending printk_caller_id() so that for IRQ/NMI > > we will have more info than just "0x80000000 + raw_smp_processor_id()". > > I think it's really preempt_count() that we want to have there. > > That has the softirq/hardirq/NMI information in it. > > So the "context" identifier of an incomplete write would be { task, > cpu, preempt_count() } of the writer. If a new KERN_CONT writer comes > in, it would have to match in that context to actually combine. > > You can probably play "hide the bits" tricks to not *ac tually* use > three words for it. The task structure in particular tends to be very > aligned, you could hide bits in the low bits there. The CPU number > would fit in there, for example. The purpose of callerid has changed. We used to keep it _only_ in struct printk_log and never used it for anything but if (cont.owner == current && (lflags & LOG_CONT)) ... so it was easy to use task_struct pointers - we only cared if cont.owner matches current and never dereferenced the cont.owner pointer. But we do show caller id to users now (CONFIG_PRINTK_CALLER), so it makes sense to keep there something more or less human readable, it helps syzkaller/fuzzer people. That's why we keep PID in [30,0] bits of callerid if the printk was called in_task(), and CPU_ID otherwise. Replacing easy to understand PID/CPU_ID with some magic hex, e.g. hash(current) >> shift or hash(smp_processor_id()) >> shift, will make things less convenient, so I think it is reasonable to preserve the existing scheme. I like what John suggests: - if printk was called from in_task(), then we keep PID in [30,0] bits - otherwise we keep smp_processor_id() in [27,0] bits and in the upper bits we keep the IRQ/NMI/etc flags. It may make sense to "promote" u32 callerid to u64, just in case if someone sometime in the future will have boxes with more than several billion PIDs. -ss