Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp360127lqc; Thu, 7 Mar 2024 22:26:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxRzmchQS3XopAsq1z7kYurPmbMVvotDQD47OGZpwsTNZcl8rIdxyVPvM9jcjlWQUaquTAacecXoE4nllUvLvDMCJEMqknHO2MF2seeA== X-Google-Smtp-Source: AGHT+IGfDZvKcAJfV+hYzfz9SWcxZXKkUk4KQizB3OPJDllp+Lw3jJK34tE9t6CWAoOv4K7pJjJ4 X-Received: by 2002:a2e:a98a:0:b0:2d2:e784:abc2 with SMTP id x10-20020a2ea98a000000b002d2e784abc2mr3277366ljq.33.1709879175478; Thu, 07 Mar 2024 22:26:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709879175; cv=pass; d=google.com; s=arc-20160816; b=X45CXoTUxtr1GCIK0thRU89NUPxz1V5q1uptb72SC9gM2T/tsIAoyHOzF1WRnvBHyl qZVrFaVV5fp9CJ80Ha7ww92UsSIVvTyIizctoSDCVEL3QWLEKmLUYOGRomPoe3A1x0j+ /n1c6d9WFbteMXDI6Bw44qaP/n37rrJx+6OsIotbMU9+Jt1bIrK2svHdZUkpY7vG9/rp Z5dz35ITnrDXtt8KA8YNY37SGP/ctmM8aQWKboKONAphCp+tsjXpyydWf0RNc7Xqi/Ym FXtqiU+eGjpgkNboTCY/mOjCR8tgMB4cm5a4s2x0zMoi53QQOpA2a2KD2l8Z18NsMX9i cdDg== 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=6+5fkC9vjuQxxxVJPri3s0yny1sOq3HWfO3ZYVT/bhw=; fh=qe7WwYMFDrX5QrGRfr33oreVU0gPeTrky5KLzaEgI2E=; b=QZDfj/bOeEd29qFkz3G3qb64zAeeI+waZPiN0Jf7sTZKx+H9ZFD93DS+SqSfSkFr5u bNGMPM3m2axQdjQwUGFuajw6ZWdBkj+68l8e7JHIzZdZ69dCmCeyZ5+eIyPwrnHgajuF qhccqE3b2CoyUVARAPnougcMIIx9Mjd+e345uhyJGuECI9ONDgQGzG+B+DbFGdABI84j akmq+2lqQx8wcv7Uhi5ewNcAQlR91FXTLIOEwWV6iiyvuNUGd31YM/kpKfsqW8SsPozR mBB/lK7QC5yJG35nNcPg0DiCD4eW9lzynVEbQxXSPsD1xvh2tV+XSekCMcevPSfbEqmS uztQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nYVoaxUm; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t10-20020a056402524a00b00568273b7676si543482edd.99.2024.03.07.22.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 22:26:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nYVoaxUm; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 33C5E1F22AC2 for ; Fri, 8 Mar 2024 06:26:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40E9836138; Fri, 8 Mar 2024 06:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nYVoaxUm" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C89EC1E4A4 for ; Fri, 8 Mar 2024 06:26:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709879167; cv=none; b=tvQyqPXSePOynGo6HUJz2FouggCchnrOSO8l/horbtvKjJYLz2dogFJ6KbqVJgPV+NBLzIs260a0nkQr3UBVF5aYYFRMTEIZAkROAYn+pBA5+svfCWihU4AcAd6cekRCQCwffHDilT5libaR8N6jmYsZ+TGl1fEEJbUGtpd+TKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709879167; c=relaxed/simple; bh=CpN8REV9h/e4ud3t/fc9HvFQvksga7ZrtfAy1T9iNNg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tU2QivMPdRy2rrS7Z7DjP09RWeAMmRVpZds3R2+OgYi6hhqsQmHeyWZWSw5jeraYIKlzLpukjQnrExWjdJerVum5f2r69rBD6fCWFIkOIyPjoYRPiJM5Xah4led2WzJBqUc9rwKnWo2IqpqqE8GWspXLTOMYumHveZUE/LQwVd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nYVoaxUm; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-56657bcd555so2017268a12.3 for ; Thu, 07 Mar 2024 22:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709879164; x=1710483964; darn=vger.kernel.org; h=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=6+5fkC9vjuQxxxVJPri3s0yny1sOq3HWfO3ZYVT/bhw=; b=nYVoaxUmjg5iBv6NGvkc8X9ei/7d6aDfjg1OeBg3M0vMFfLANV5vEqYuDE0LjAPaU6 nDHW4/C+VIMEQOS7VYN/kNy4/dkQfddKcGxSC+oxxQJiCbYkyijYngcIK8oKhF1mNE+8 +XqKXeuEX6l7IpZG7qnybbTRcO8VUAwZy6WEydbPkWHP2swfgTouS2rO+KQTg1ltj5UY MFt/nFtpq7gqCvkoF5co7pbpuaFndzhSEcYw+YFulm2F6PrOxOB3U1Ofc4uF+nA0LpIb MF8wczHrMvi2tcdtBpRPeDL2ucRPg0ukYLNnOhGC5RymWeD6mmp2qnYIb7F1hqxbvbqk Yhfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709879164; x=1710483964; 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 :message-id:reply-to; bh=6+5fkC9vjuQxxxVJPri3s0yny1sOq3HWfO3ZYVT/bhw=; b=hjFFWm3OIMlzLFFrQxiYSpyfAv6QHWCZ7SgRq+6R5LQeg3X8wpFJZuYY9NF8BI8+OT EuESyLMLmdqczmGo4Rh7B7tU8yXJUk9GH/39aMbcR5kyvYcrZHTZCFlaTSt4NmWfhBAh 2cjkll89EPOsJmi/rO10GC9eDyT1smzRHvHelM0oMMrwTOp3CRjXZ3R0fxlsdEYkBuMV G+Q3BGAt1vpGBvoJ8emJBWyuNQHn2ZVhZ/rVwaa5RU2eYGIG2s/DYayi2UBLk9i6Zdip Sr0RopD8lkBRTNPSlDm5Sl16xV9VAIRf0lED/NvVQdyqygWSUmtt9KBbtgASgYHvdyzU qh6w== X-Forwarded-Encrypted: i=1; AJvYcCVanbMp09L8n+ohbSM1Sa/gwVFCTxIToCh1O1LVGzBsEyuPuSt+7ros+vU8C7m53sq2+jYyD6fTyZJn3OyNcfwka9ppytPBx5TZ/4x6 X-Gm-Message-State: AOJu0Yx+vJvo6sjsXX89NrP4pquLIs1ebuN9O+1zGOZGw5/NvWzYeG+5 Bf+Xi7MdDW7p3hhJc1zrpIF7z+Tdvz33Z7GkCdJIt0U3IJyVC+EGyZ31MX0= X-Received: by 2002:a50:d554:0:b0:568:1bd8:a617 with SMTP id f20-20020a50d554000000b005681bd8a617mr957846edj.30.1709879164044; Thu, 07 Mar 2024 22:26:04 -0800 (PST) Received: from p183 ([46.53.254.187]) by smtp.gmail.com with ESMTPSA id d8-20020a05640208c800b005682f8b62a6sm134785edz.97.2024.03.07.22.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 22:26:03 -0800 (PST) Date: Fri, 8 Mar 2024 09:26:01 +0300 From: Alexey Dobriyan To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sysfs: make sysfs_emit() return ssize_t Message-ID: 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=utf-8 Content-Disposition: inline In-Reply-To: <2024030713-favorably-liking-2135@gregkh> 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. > > But it is better to do sign-extension once inside sysfs_emit() > > then duplicate it at nearly every call site on 64-bit. > > Why is that better? Does this affect code generation? If so, how much? > And to what affect? > > And the function itself really is dealing with an int, it's up to the > caller to want to do something with that, not the sysfs_emit() call > itself.