Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2091993pja; Thu, 26 Mar 2020 09:34:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsWbJwTEQ1RElevdzB4UR8soDl0oiBZtIYuVaYQoRat9k17TF03kmNbIDS3gKQx/nZsslok X-Received: by 2002:a05:6830:1051:: with SMTP id b17mr7161054otp.157.1585240446531; Thu, 26 Mar 2020 09:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585240446; cv=none; d=google.com; s=arc-20160816; b=oPJ6nFdjoCYX/YGd2tjkCgOIQAwtzBrnFW9Vh+dFs+KyifRjAzCO+PBDsB5TLwlK3Y XO9VGsO2qln/N9r69hyFimt8XzHxB2xVL5uiOFaPGY8Um6T5eWLHiF16JgWZCjhHsAA+ Rden5QxhWssUkXSUL6nwejWEpZlqJ7NeiE/3pURpHwL2DX6eK8gjcaOkqQrOptgJL6j5 Uj+71VATjNkmGSiI+YkrRHH8xjPqGaYeY14Drt/nA82fS02LqAPL1slIfKbDFpBH1LWY a69jGe2P4JS5dd25S8fQxIxvWLPjBSQvdZHoUpWcBJC/FBtRZDO2qCOU4vs8WCBfbKOD 4W+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=/J9DKIJKhoNAqIER9UasEoSb9g40NhzAqb5br/ibrT0=; b=T1+jv+PwWO1qNHTP3CcQeTNy6FuYONeH+dMlc8BAhSGlYfD1aeDSWlrY5T5nHcg995 YG5I9UKq8WSFy/mRyFhfkusg4yyTInAPa5aBySSVYQBMXFltcVS8Z4qHgzSdzJfWhny4 X+SZTYk+H5I6VryXTuDUUQLXX+eCCmpdvXzd0pPcVGtP4pgxq7eza6noTIDXJ3thD+vr DUdiK1it30TJKpTJxgGRO+uLZhjGJcV7xxYznoZND0SJ58sb+noCxouNHKUcKZECtWIf K+vz35QEuGFT64PsU2Nrx7c4xB09Dtu0rEjWeU2apCd5OJtx6ZibTl+ViYDCkYxoaikH DRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=beSw2q4S; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t144si1209330oie.129.2020.03.26.09.33.42; Thu, 26 Mar 2020 09:34:06 -0700 (PDT) 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=@google.com header.s=20161025 header.b=beSw2q4S; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728479AbgCZQdI (ORCPT + 99 others); Thu, 26 Mar 2020 12:33:08 -0400 Received: from mail-oi1-f201.google.com ([209.85.167.201]:52967 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727752AbgCZQdI (ORCPT ); Thu, 26 Mar 2020 12:33:08 -0400 Received: by mail-oi1-f201.google.com with SMTP id c123so5152153oig.19 for ; Thu, 26 Mar 2020 09:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=/J9DKIJKhoNAqIER9UasEoSb9g40NhzAqb5br/ibrT0=; b=beSw2q4SdKcg2ewSfNyzPzqQi7r3biZrSQXp2knPVxfAerelXJjmhK9TCYS7rW12ie aTfz4SLt5zbajIBh5cWhhcq5lEyvYrN4uGoXQZnwbJWqrq3tjKl9b4tWRK00frEKMoOd x5BZCE6CXh6GWMjkOchwFfFL0bdrCtl7EhdrEa/6cugeK0y3wR4KzQobSR/39xve71eZ KNUzTShRtOJMZTRegK23KRRi8V/m8GTBht1NvCfuAfGyD73L/1/j5P0SRjukQ7C5oAq0 7FHVxIAjG3yXjk0ncnwiH2N20DUV+YIWeZ8KfdSdB5+zmd+nwxbX354Ym7/YIv73XaeF R8Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=/J9DKIJKhoNAqIER9UasEoSb9g40NhzAqb5br/ibrT0=; b=FLoPr+XwEGrtcAf8f8R13EuCqAnsUX55xNPWMbBBEAt5wxn0oPtu6z+C5NGas3CISK OJlKv5ppSLmsdGuvweWTonjGR052JPL7pVsKFZ/ZNUltl+W3ZGdchOve+vFcFU2qWxMn YqV5nRwAxnBR5eKuCT7W/Fsacb1FRzeMCj52BHXDdLyqcuAaZejXv3uempJECG0FRcOY QhBnkFVOCYgXPUn/P0jB8iJZRhhzcSVyVA6t8D/dRCLzVlv181xb2ai+nrcGR9IxRhN4 J1l+OxT8DzBDoembCsLblyA8dQZ9uWjUDIUnd1PviL56/k/829W1ZJixDuZ/45qbR6Tg ID5g== X-Gm-Message-State: ANhLgQ2LUuwgpXbxlxY5VIpsAvC5zmdJmp1SWpZahr0SrBvHRbZKMy7E I314mJiaxCHPeMStyNn8nmIoMMlXNw== X-Received: by 2002:a9d:8e4:: with SMTP id 91mr7312036otf.130.1585240387114; Thu, 26 Mar 2020 09:33:07 -0700 (PDT) Date: Thu, 26 Mar 2020 17:32:43 +0100 Message-Id: <20200326163245.119670-1-jannh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH 0/2] Make printk_deferred() work properly before percpu setup is done From: Jann Horn To: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org, Dennis Zhou , Tejun Heo , Christoph Lameter , Steven Rostedt , Thomas Gleixner , Frederic Weisbecker Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While I was doing some development work, I noticed that if you call printk_deferred() before percpu setup has finished, stuff breaks, and e.g. "dmesg -w" fails to print new messages. This happens because writing to percpu memory before percpu initialization is done causes the modified percpu memory to be propagated from the boot CPU to all the secondary CPUs; and both the printk code as well as the irq_work implementation use percpu memory. I think that printk_deferred() ought to work even before percpu initialization, since it is used by things like pr_warn_ratelimited() and the unwinder infrastructure. I'm not entirely sure though whether this is the best way to implement that, or whether it would be better to let printk_deferred() do something different if it is called during early boot. Jann Horn (2): irq_work: Reinitialize list heads for secondary CPUs printk: Reinitialize klogd percpu state for secondary CPUs kernel/irq_work.c | 22 ++++++++++++++++++++++ kernel/printk/printk.c | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) base-commit: 76ccd234269bd05debdbc12c96eafe62dd9a6180 -- 2.25.1.696.g5e7596f4ac-goog