Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4119492rwe; Mon, 17 Apr 2023 08:12:34 -0700 (PDT) X-Google-Smtp-Source: AKy350ZPjeGSsEygWM8NyinvGJiPnQkQVMtndBotqUXvpG1DfFuhngI8XYDlUFIobkz0j7m+6CrG X-Received: by 2002:a17:902:c78b:b0:1a0:53f3:3761 with SMTP id w11-20020a170902c78b00b001a053f33761mr12002365pla.15.1681744353921; Mon, 17 Apr 2023 08:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681744353; cv=none; d=google.com; s=arc-20160816; b=eootKxb3TdqQKf52CGUcV36X5CaY8uekQ67UlMyiRnr5JNX25nhHHWoFrS1D/eHPIs w3RTHjnsfZfs0LvRjXU750eNd6wvCU+Q/sQvXn+X1xuJdby9ZgH7RHDIr3oJihdUdWVO 8z6a56D/+d8Cm18XVHLrPAbcb/m26DzeWtK4UV/Kk/cuSYfhXlT1cHTnubJMlpWVUuD8 5xBawAox2mIWVXlaCAE2JIz/9BbOEbBXkcdGUsBZE7gcH3N40E7xYJlmLi79S0Y3Ag1V JZX5DI5I571xiwY7PmBsxHMcKJGeimCOxAxwyAUGskHeLqqSoTKNQWqG+I9UkYRD3QuW iqwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=r289gp/zTqEKyD+xyIg8Q8UOxcZRtz7DHOB0I75vTG8=; b=KetN2lmjnu3FzY9HNcZTKvujmAwjn1NuxcivVtbCA3qU99RjKVgU6K44YED5MTqrow FassdEAv6qv9oH58+x3iBum4mvt/s8J+qDzOf+Q2SKZ5DK1Y3VhOQx4C+6mHHr7yF79x 6U1VScxKujGsirkB4oxtar+YvD+NqyhMqZv7VQIZasyd1CSnT6BGvPj6p4Zy+XOHwzul YDtWt6a38eB3lgU8CW4TphSu4TR+zOJkvqV+2bYIYxatu7Mb+a1USrLL0WP+/UmrhY96 M8LUYo4HjPT0IhgeGyPuVNgOunC79n/tbBCC6wUl4NWKmidi1MQm84a+CQlj6sE8twLc by3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=cAvnOsdo; 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=chrisdown.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a170903110800b001a52c82907bsi12714779plh.191.2023.04.17.08.12.21; Mon, 17 Apr 2023 08:12:33 -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=@chrisdown.name header.s=google header.b=cAvnOsdo; 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=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjDQPEe (ORCPT + 99 others); Mon, 17 Apr 2023 11:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDQPEc (ORCPT ); Mon, 17 Apr 2023 11:04:32 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A4619A2 for ; Mon, 17 Apr 2023 08:04:31 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id o6-20020a05600c4fc600b003ef6e6754c5so11857755wmq.5 for ; Mon, 17 Apr 2023 08:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1681743869; x=1684335869; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=r289gp/zTqEKyD+xyIg8Q8UOxcZRtz7DHOB0I75vTG8=; b=cAvnOsdoix6d8t7QMzHIiWPB6xAJyYE11peuEko54zFQduh6mUzEVC0JabN1NFJM7x zQ9faT8q/ASPquFaIqNpcjUmldYanm3GRlX62CINGX/qcZlZSBkQ+Thaeg9JWGKDrZ68 oJBUu1tr5U/WKhZMLhWYZ2tLr9y/lrwR6dLvM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681743869; x=1684335869; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r289gp/zTqEKyD+xyIg8Q8UOxcZRtz7DHOB0I75vTG8=; b=Mx+9diGpfQKZDyeXC2Ev1wykFZEKwzyYycZF6xQ53eISCBqMPOje/vT2oohz9iIHDH jUSFZaAM/ETiLk7lQganxJ09wjnmbQtZ9OkZ+R8hiZeK7d7GSHOXzxFGIOFBO+nJ1OEa EtpzMl0goYBFhFuyIJZyZ952IuOUzP9KhMNT6MpQRi/ilZI0v2FsO1mOHP02iTP1871J M3CbJYA0epak3vDMu19FWVEcvPHyeOHTlHKUhgCr3IzvIeC5DhzFnPWt3m4/iSUKWi4L 61Ytot/QPpFtRCmAm15WUgUL4Y3TvmF1MJSwZpEPa1rQQ6Ze6YALMkqyADSi1uto12+N /h3Q== X-Gm-Message-State: AAQBX9cyRwUSpsh9LReOLucrDjHiJdFefyHILggy6TAM36GhQ7UsJz76 8mcmWZc4k2XB9KVyjpAFuNjIlw== X-Received: by 2002:a1c:4b04:0:b0:3ed:4b0f:5378 with SMTP id y4-20020a1c4b04000000b003ed4b0f5378mr10808591wma.27.1681743869556; Mon, 17 Apr 2023 08:04:29 -0700 (PDT) Received: from localhost ([2a01:4b00:8432:8600:5ee4:2aff:fe50:f48d]) by smtp.gmail.com with ESMTPSA id j6-20020a05600c1c0600b003f173987ec2sm3243185wms.22.2023.04.17.08.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:04:28 -0700 (PDT) Date: Mon, 17 Apr 2023 16:04:27 +0100 From: Chris Down To: Petr Mladek Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , kernel-team@fb.com Subject: Re: [PATCH v3 1/2] printk: console: Create console= parser that supports named options Message-ID: References: <732ee897b2bd49ada3f7dee396475c5a2195071b.1658339046.git.chris@chrisdown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.10 (2023-03-25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 (To others on this thread wondering about this patchset, Petr and I have had some discussions offlist about v4 and it should be up soon.) Petr Mladek writes: >I thought a lot how to do it a clean way. IMHO, it would be great to >parse everything at a single place but it might require updating >all drivers. I am not sure if it is worth it. > >So, I suggest to do it another way. We could implement a generic >function to find in the new key[:value] format. It would check >if the given option (key) exists and read the optional value. > >The optional value would allow to define another new options >that would not need any value, e.g. "kthread" or "atomic" that >might be used in the upcoming code that allows to offload >console handling to kthreads. Any thoughts on something simple like this that takes advantage of memmove()? This should overcome the mmio/io concerns, and it's fairly simple. --- static bool find_and_remove_console_option(char *buf, size_t size, const char *wanted, char *options) { bool found = false, first = true; char *item, *opt = options; while ((item = strsep(&opt, ","))) { char *key = item, *value; value = strchr(item, ':'); if (value) *(value++) = '\0'; if (strcmp(key, wanted) == 0) { found = true; if (value) { if (strlen(value) > size - 1) { pr_warn("Can't copy console option value for %s:%s: not enough space (%zu)\n", key, value, size); found = false; } else { strscpy(buf, value, size); } } else *buf = '\0'; } if (!found && opt) *(opt - 1) = ','; if (!found && value) *(value - 1) = ':'; if (!first) *(item - 1) = ','; if (found) break; first = false; } if (found) { if (opt) memmove(item, opt, strlen(opt) + 1); else if (first) *item = '\0'; else *--item = '\0'; } return found; }