Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp173630iob; Mon, 2 May 2022 16:16:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAME/X4aaktsgOhV/JZkx1q5KmVvlTw5BB6RmOxle+8l7KM9VYmM66Wxh0URTaHWAvOfDG X-Received: by 2002:a63:d145:0:b0:3c1:4ba0:d890 with SMTP id c5-20020a63d145000000b003c14ba0d890mr11444231pgj.607.1651533379371; Mon, 02 May 2022 16:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651533379; cv=none; d=google.com; s=arc-20160816; b=ia//pp3eabkzIyHiXiX30tiOgyZt30qrwP9d0Unip96yWmcl8OoCea2V0NfuJGBIZu aYxB689E8FOiK/9da/ochL8ZOcPp0w0J3q2//C4ijd35YGoo28KDVQi96zrPJvfReNd3 ecEaErQeeD8UxKdLZiumrDZUQ7E3KQVDJ9SwWQXTfSlKX3TQa5fsQK27fp8NSd8Np5aw sMsThI2t+67H1lGEaj4Yuo1/Sf1qdorP18hl2ZQ2qNcVzHJ5dREAF7XoXtikNLUM1sL5 fSNBCKlQ1lOCRcWrfTFb4jJFL1SXDQAHXAXZ3vrBNknVBunOgzQ+Osa35X13l85znmhW hjCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=JYiEoXgZa+1xAFGzJ6pdbgZS9bMkYlHMr5G8hxuq7k0=; b=XCFiuxkBiLbzwa0qvxLiKmgIPSEYBjc2F8NWxWryi/9LkGpW7z5hPik6YEmoOHYw0M tDE72T07ZyKJPRPEBBVELdcX6EQZ36bZNIMdYb9zZ3m6d3SnMFZZxJHGU0Hvjs7TbR9I EMHtA0ubtPSbCZepVJs0P+1zIBFThLbj5U10utSsfcYIwDptCnyZ7sv10JWAm5AVc5fb U9GQrRlBbj1EtZojXNgOwyyulJCmDi4Gav5p8BCFW4YU7E8uMs+e0WNcG1jlRwT4Ctaq Vx9yrOttD2UPs7CcD0mPxwqKtwOp02eUJtHO5xeAB538hcPY+amjrRohNei1Mh3MVG4i F/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="X5/Hv1sz"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id kb12-20020a17090ae7cc00b001cd476d0e71si716876pjb.82.2022.05.02.16.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:16:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="X5/Hv1sz"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BD4A21FA53; Mon, 2 May 2022 16:16:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245281AbiD3VLj (ORCPT + 99 others); Sat, 30 Apr 2022 17:11:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233148AbiD3VLh (ORCPT ); Sat, 30 Apr 2022 17:11:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 587A8644E2; Sat, 30 Apr 2022 14:08:14 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651352891; 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: in-reply-to:in-reply-to:references:references; bh=JYiEoXgZa+1xAFGzJ6pdbgZS9bMkYlHMr5G8hxuq7k0=; b=X5/Hv1szmlnx+Kn4ZVFxkz6yfaMIt6UJ+l1gY8T/a9sG0fqV6nIwpUMxSmWEhoRWuWGkUf pw6spnQlELZ2G7HacGwrDq7/RWAAix7kyb7bHlFcOzjSSClc0GssKym4B0ZdtbB4NUaN3w 0q4BDOIEz6gigZA0s6uqWtNw7Fg/O/O/BvM9Om6BsdyH5Ck7dctYYgArOt0Sp6r32/9X1W GjPXgN99BYpZItZfVhUFqvXd5S8Wz0mB+k7reHJyIp6AxxSU5Y4pby8R+Lme/J7lgCpNVa O6OJ9WgQFC10tOvqwbGyHuRELT8BxVaCvr9J4pvKTkoMimgdw2PUvOpkUQf0zw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651352891; 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: in-reply-to:in-reply-to:references:references; bh=JYiEoXgZa+1xAFGzJ6pdbgZS9bMkYlHMr5G8hxuq7k0=; b=P4+uquywNx3JFpUdyBVMRf/LWCCPvN3ivrNp3YBAvJLOvyGr87StS76UpIdomH9o8F0KTN IaZ2p7Pc009IwgBA== To: Marco Elver , Naresh Kamboju , Petr Mladek Cc: Linux-Next Mailing List , open list , lkft-triage@lists.linaro.org, linux-mm , Andrew Morton , Alexander Potapenko , Dmitry Vyukov , Stephen Rothwell , Anders Roxell , Andrey Konovalov , Andrey Ryabinin , Catalin Marinas , Evgenii Stepanov , Mark Rutland , Peter Collingbourne , Vincenzo Frascino , Will Deacon Subject: Re: [next] i386: kunit: ASSERTION FAILED at mm/kfence/kfence_test.c:547 In-Reply-To: References: Date: Sat, 30 Apr 2022 23:14:10 +0206 Message-ID: <87fslup9dx.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marco, On 2022-04-29, Marco Elver wrote: > And looking at your log [1], it shows that KFENCE is working just > fine, but the logic that is supposed to intercept the kernel log (via > tracepoint) to check that reports are being generated correctly seems > to be broken. > > And this is not only i386-specific, it's also broken on a x86-64 > build. > > At first I thought maybe with the printk changes we'd now have to call > pr_flush(), but that doesn't work, so I'm missing something still: > > | --- a/mm/kfence/kfence_test.c > | +++ b/mm/kfence/kfence_test.c > | @@ -73,11 +73,18 @@ static void probe_console(void *ignore, const char *buf, size_t len) > | } > | > | /* Check if a report related to the test exists. */ > | -static bool report_available(void) > | +static bool __report_available(void) > | { > | return READ_ONCE(observed.nlines) == ARRAY_SIZE(observed.lines); > | } > | > | +/* Check if a report related to the test exists; may sleep. */ > | +static bool report_available(void) > | +{ > | + pr_flush(0, true); > | + return __report_available(); > | +} > | + I am not familiar with how this works. Is the tracepoint getting set on call_console_drivers()? Or on call_console_driver()? If so, there are a couple problems with that. First off, the prototype for that function has changed. Second, that function is called when text is printed, but this is not when the text was created. With the kthreads, the printing can be significantly delayed. Since printk() is now lockless and console printing is delayed, it becomes a bit tricky to parse the records in the existing code using a tracepoint. I wonder if creating a NOP function for the kfence probe to attach to would be more appropriate. In printk_sprint() we get the text after space has been reserved, but before the text is committed to the ringbuffer. This is guaranteed to be called from within the printk() context. Here is an example of what I am thinking... --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2227,6 +2227,10 @@ static u16 printk_sprint(char *text, u16 size, int facility, } } +#ifdef CONFIG_KFENCE_KUNIT_TEST + printk_kfence_check(text, text_len); +#endif + return text_len; } The probe_console() could attach to a NOP function printk_kfence_check(). John