Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp417488lqc; Fri, 8 Mar 2024 01:01:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYGhQWmUjVSoc0o+FywI1mCpN9118YC1YlCtowE/+eIfBha4Z4Zavyj16E4vyUmOcxp7a+Phjx7Ox7G/Cc6PqG3jbd24HrerXVrVa4jw== X-Google-Smtp-Source: AGHT+IEPi9cr+cWb2vFsDeyskwG05PGr3VDP+EcHMI5nQVVWGglVrl6JuyjP8LF8I/0K9w0Bfvl7 X-Received: by 2002:a05:6e02:1748:b0:366:228b:3141 with SMTP id y8-20020a056e02174800b00366228b3141mr1980689ill.32.1709888501563; Fri, 08 Mar 2024 01:01:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709888501; cv=pass; d=google.com; s=arc-20160816; b=CZOy0LEaXw502XqMD8KGj+e6hYbdq8Xg3r2Px+0GQ9ulniZC01FXOdPYSztedTtgCx M75nZdNs/Z50LIypbQ7I8tZCKmB65SgJiCAAvZBu9484CYSCgZT0iTcAqE6U/GU2Fsv7 Giu0b0VLpW/KUX5Y6Xxh5h+srVm+VGaFjoWnTPOXNZTAZ7BdA3yLYf0IBCkEW8mk1qxZ RNKdb4W9YIhvPrli8vIKBgL6kXEHPmOaKwY2H30IPqQxUObW0lSG/K1B3iblVhCC57Lk UKibBsPl1yhZO1TBaFZSNiWfqoWxixGXTAG7hzPkD//FS63MYLjmPyOiSOjzOwftYJWv MKDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gnPQF7jxFKOYsNO4eOJCL4Jyh5atVoUCc5uf8Dnaw10=; fh=i+4H2CHZ/3qk1vqktUbN6XNjumFyjT9ZiUuLE1pPKME=; b=ixyLeTuwr8ma3k15Zr6jv1m2PfyKShlsMoSGr++xR8QJwDKwpdfaxtCpN4jD+9npAm K6cJ2L+CKoZYpYQ+h0TsbbUDAh1QBv8lAf/K5IMPLBJ4+sfCc8f+FlzZKxt8nPLRVnAW y3ZYlwwHk6ZOBfZATRxHn4eQkc5pdXBW9Sr8aT/RrfKZTsUCFYKJCY9FOZFd1Xx750YU DbgVjFL06JCtN+Sjzc4CVLVmsKM5iHiC8NlAR9b4GS4cBRrwJcF2Fp199YfKvluKJWtn ZPd2FfxTGoGXIEC23x8/r/b2nkgw/nSgXbHIAbR/HXrkzOENf2CCeJSOE9E5QpKNjYHy G0eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D2JyF2v1; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-96719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h6-20020a635306000000b005dbc6dc4cdasi16245531pgb.255.2024.03.08.01.01.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 01:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D2JyF2v1; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-96719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3AF252810F4 for ; Fri, 8 Mar 2024 09:01:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 124B05339B; Fri, 8 Mar 2024 09:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="D2JyF2v1" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A3E822626 for ; Fri, 8 Mar 2024 09:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709888487; cv=none; b=GvTjIR+n5C3rPsV88HgwAoE/InjLbjRiJThrgs9lf1//IBrJ5fro5NIlb14p/wbfp/dywaQa0mDLmCdURnLylnel8jah5+O9hD20AVPrCjdcnmGPHJGpYV5jFE1qM09zaM4KM85x+qdehlTfcb/v1F5iJ4t5eEyLfPQN4Oic7f8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709888487; c=relaxed/simple; bh=/5ZjGBbYQVs4I+O/KoTJ+PVJQE4K/gaDCvf4loCIOGI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=e0v5/W/qCG3n8iNuciWICIOSLfjv+Uh8OxsyMDuWnXhGIR0tUVaP9BHqBKXKqTF2udN7UIKOFHI/Kxp9PNrwWS+9fSDgPcDdJr3sWQhcE1j0HTQZtTRnUIKSArbjwAdGl1X9PAL5zCFPyneV+C8sIzAaa09g6oawpnXV1JoAhRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D2JyF2v1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 525DCC433C7; Fri, 8 Mar 2024 09:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709888486; bh=/5ZjGBbYQVs4I+O/KoTJ+PVJQE4K/gaDCvf4loCIOGI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D2JyF2v1IMkmwBvvv15cch7DK49/EqwkS6LPMWUb4gWr+tJXGC6bEw+HSDVqdKQcp sBhDRag/vaymwj2+H5EycoQr0zSmB1N3Mp5LbM5J16cmkp7ZCc/9uAtjK+GEuLjtPY +4jc0x2YoyyLTeXsUuIIVOpeYzE8WWSGPw8DJpmI= Date: Fri, 8 Mar 2024 09:01:24 +0000 From: Greg Kroah-Hartman To: Alexey Dobriyan Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sysfs: make sysfs_emit() return ssize_t Message-ID: <2024030803-bulk-grader-3ad1@gregkh> References: <33cd8f96-4b4f-4741-ac05-ef1bd267ce6b@p183> <2024030713-favorably-liking-2135@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Mar 08, 2024 at 09:26:01AM +0300, Alexey Dobriyan wrote: > On Thu, Mar 07, 2024 at 10:04:41PM +0000, Greg Kroah-Hartman wrote: > > On Mon, Feb 05, 2024 at 01:11:36PM +0300, Alexey Dobriyan wrote: > > > sysfs_emit() is most often found in functions returning ssize_t > > > not int: > > > > > > static ssize_t oops_count_show(...) > > > { > > > return sysfs_emit(page, ...); > > > } > > > > > > This pattern results in sign-extension instruction between > > > sysfs_emit() return value (int) and caller return value (which is > > > ssize_t). > > > > Is that a problem? > > Small problem, but, yes. > > If sysfs_emit() returns "int", then every user compiles to > > call sysfs_emit > movsx rax, eax > ret > > Given than sysfs_emit() is the official way to print in sysfs, > there are lots of users and there will be more users in the future > as it grows. > > This trailing "movsx" instruction is duplicated every time. > > If sysfs_emit() returns ssize_t then it is folded into sysfs_emit() and > appears in the code _once_ saving bytes. > > Ultimately, all this confusion and mismatches come from snprintf() > accepting "size_t" but returning "int" (despite working on very large > strings!) which sysfs_emit() copied. True, then why not fix up the base function here, vscnprintf() and vsnprintf() and then propagate the fixes outward? thanks, greg k-h