Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp573439rwb; Mon, 26 Sep 2022 03:06:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6016VMjX+iV9CAXo5GKSEvp4hAcBQ3mXMpnRRHN16oulgpX/LIDODAtUlsCeQ8vHs8mAqb X-Received: by 2002:a63:4904:0:b0:439:e6a4:a3b5 with SMTP id w4-20020a634904000000b00439e6a4a3b5mr18378060pga.182.1664186782551; Mon, 26 Sep 2022 03:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664186782; cv=none; d=google.com; s=arc-20160816; b=p/e/iLCMOkcB8N16d06E234LELm4OA6PUOhHjlR7UUHQooQt0wvYh9weoCKlnM1+qA 7LdT1I3VQAGVzoOGxO38DHyiCq4iGEtaWU6haFw3Gb9eU1950eKxEW7cZgLCV67DbyAK nY0MNBgG6rb3hJt7HTIeh5FeI83h3YzhwX3Ig4/8m3ppkYiDMQRGlOc2YZXTylhWCuoC /03RwjwUTGWE7T5cQqD7YjEuth8FtNpq4mRggU0YRgIewHEEooBX/yY7zuZ8/gKn1SMn 43HgnNhnvbpZ728c6SbwpVtXeIWnkA5+HpqtBB4DXF7k9fMVDVz2ogcOVUwoHgLGZ3fb c7vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MPn6a20lGPjczB73AXADasqkPzFa5QqvxnfB30lgZnI=; b=osezIkBD/UKf57RRb6fZWH1dwhoWdO0OG2cNrXyJ4LayihNm5UuhsQBbuQobFY2FYk VFhYe2IQHNcKTEZgIyrfYaY2JdgQX0o8lbu4lvE187c5Y6xCDpMbRxlfRc9rKLx/xBKL 0en2rsbHPDOWLCCmjgoIYW6zA+pfq+aSvI+6Spl65FVWKvZUfuaWXrpBP95N/J8Pak7b 8g1+NPHQ8CL8AK4AxG+K2A0/V/WBsDTL7WxDo0Fe2Y/NKD9sRSROrZfWZaK2n0wgj9oj mrGHfx7je8Qn/rJ5gOs69dYFBcuCNhpXI1vVFNafPX00X8rJ5tt1JVrk3RC3wSnAJFoB peJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nXTHZo4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a170902e5c700b0017531071bffsi13917234plf.104.2022.09.26.03.06.10; Mon, 26 Sep 2022 03:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nXTHZo4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234048AbiIZJVk (ORCPT + 99 others); Mon, 26 Sep 2022 05:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233222AbiIZJVL (ORCPT ); Mon, 26 Sep 2022 05:21:11 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D152242AC1 for ; Mon, 26 Sep 2022 02:18:57 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id 9so6033629pfz.12 for ; Mon, 26 Sep 2022 02:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=MPn6a20lGPjczB73AXADasqkPzFa5QqvxnfB30lgZnI=; b=nXTHZo4VhcwYUndpnviY+WdPnUQHhydHnFwHNGsRUgPdFHA3f9I+VL/twlx0ysTtc4 1XA/3HdmejoO1gfByTU/ohK2Z/L9zIf61aVtVnjuQQ+ac1p8p3uE73f8JFlH04aNsyY8 MuoyfmaLRRK4SRqblHLfrnbC27P+QlWmfDBEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=MPn6a20lGPjczB73AXADasqkPzFa5QqvxnfB30lgZnI=; b=a/IGNPgG4PTybwgfC38no6X5lmbYbZlDKDvDaXg4qWEWQzSHOgAoOCJCRX9xwj6ogn EZfa5lyWL7ueca2gAbG0H9vqL+bRnnWs2imFYK0q2Q5DGk3hMYfRfxpubQufA6VGOD79 p/45Aarrj9RCTN5oxfI82HezIDfNObRS+nbSl5mQE4p+v8pYicnxyBhm+gE/YVcs0tCY WyZdBJxneXKDzFzVFrEKicb9CnJ1q6fLK1caJkKMIbeu0bY7GNELi+X2z3borUa9leCn Rk91c5tTlVkD2Up0Ss1GIlE6+JLM9AhbSUIP54rtKdsOobCFzXt8kO0+oqp211BfQgNF DtHg== X-Gm-Message-State: ACrzQf0OHMFNavXbzEtSTVJ+CuvEbuXk8y8bCzktRbad2M3ipSIIFIVu gDX0lCBQu3suyVDYLljzpCoTDg== X-Received: by 2002:aa7:888d:0:b0:538:328b:2ffb with SMTP id z13-20020aa7888d000000b00538328b2ffbmr22809720pfe.82.1664183918481; Mon, 26 Sep 2022 02:18:38 -0700 (PDT) Received: from google.com ([240f:75:7537:3187:2a7d:69c:905d:1926]) by smtp.gmail.com with ESMTPSA id f11-20020a170902684b00b0016ee3d7220esm10853134pln.24.2022.09.26.02.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 02:18:37 -0700 (PDT) Date: Mon, 26 Sep 2022 18:18:33 +0900 From: Sergey Senozhatsky To: John Ogness Cc: Sergey Senozhatsky , Petr Mladek , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH printk 18/18] printk: Handle dropped message smarter Message-ID: References: <20220924000454.3319186-1-john.ogness@linutronix.de> <20220924000454.3319186-19-john.ogness@linutronix.de> <87leq6d0zn.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87leq6d0zn.fsf@jogness.linutronix.de> X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On (22/09/26 10:00), John Ogness wrote: > > Oh, hmm. This does not look to me as a simplification. Quite > > the opposite, moving cons_text_buf::text pointer to point to > > cons_text_buf::text - strlen("... dropped messages...") looks > > somewhat fragile. > > It relies on @ext_text and @text being packed together, which yes, may > be fragile. Right, and this assumption can be broken by both internal and external sources: new gcc/clang plugins, config options, etc. > As an alternative we could memcpy the message text (@text) > to the end of the dropped message text. There would be enough room. > > Generally speaking, the dropped text will be less text to copy. But > since dropped messages are rare anyway, it might be worth copying more > data so that the code is not fragile. It would also allow us to remove > the __no_randomize_layout in "struct cons_text_buf". Agreed. > If the end of cons_print_dropped was changed to: > > memcpy(txtbuf->ext_text + len, txtbuf->text, desc->len); > desc->len += len; > desc->outbuf = txtbuf->ext_text; > > Would that be OK for you? Yes, this looks solid (nothing should be able to break it and cause mem corruptions).