From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCCCFC2D0A3 for ; Sun, 1 Nov 2020 22:06:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF84722282 for ; Sun, 1 Nov 2020 22:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fLt2r7cm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF84722282 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 164E56B005C; Sun, 1 Nov 2020 17:06:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5626B005D; Sun, 1 Nov 2020 17:06:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECE8F6B0068; Sun, 1 Nov 2020 17:06:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id B64206B005C for ; Sun, 1 Nov 2020 17:06:11 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 538863620 for ; Sun, 1 Nov 2020 22:06:11 +0000 (UTC) X-FDA: 77437233342.14.rule23_1300a64272aa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 3B48918229835 for ; Sun, 1 Nov 2020 22:06:11 +0000 (UTC) X-HE-Tag: rule23_1300a64272aa X-Filterd-Recvd-Size: 3577 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Sun, 1 Nov 2020 22:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=auZJL386i9bjm2MWt5wDlaf7Q2dtUWWeL5G9LrgakYc=; b=fLt2r7cmGvPtur84cW6FZ2N+Jg Nctqmd906xfHrHReBe9tl9Hiw2OHQ9UgvBdYOA8j6yc8GJpVQpURm4+cnxpexuiXHVAVWvdBu6hwV aNTO2IY5gHf1orO2e2iud8ZMrVKWFVCkE+IjJ2sDrsrMBREHSI0hWERxBluh5BA+ZBbQc2tSxd652 i2FlVzD99bJ3wKG13SifoeBWkiOroAVPk6pZrD7h7n/wFGrbUR265tT795rYwllEaHBMDjMiBeWlo wMNVlRzYkaJ1ltfQ5BcDKVz3gcwMQ+XhnslKZFCg7Yx0YVq0dZtXV1OKITKD63BzBP9I8NdbkEEFu c99tzW/Q==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZLUC-0007bx-7K; Sun, 01 Nov 2020 22:06:04 +0000 Date: Sun, 1 Nov 2020 22:06:04 +0000 From: Matthew Wilcox To: Joe Perches , Greg Kroah-Hartman Cc: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] mm: shmem: Convert shmem_enabled_show to use sysfs_emit_at Message-ID: <20201101220604.GI27442@casper.infradead.org> References: <20201101204834.GF27442@casper.infradead.org> <616b92af9378e9f9697555074bba1e377450477f.camel@perches.com> <20201101211910.GG27442@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Nov 01, 2020 at 01:43:13PM -0800, Joe Perches wrote: > > Why did you change this? > > Are you asking about the function argument alignment or the commit message? The indentation. Don't change the fucking indentation, Joe. > > Look, this isn't performance sensitive code. Just do something simple. > > > > if (shmem_huge == values[i]) > > buf += sysfs_emit(buf, "[%s]", > > shmem_format_huge(values[i])); > > else > > buf += sysfs_emit(buf, "%s", > > shmem_format_huge(values[i])); > > if (i == ARRAY_SIZE(values) - 1) > > buf += sysfs_emit(buf, "\n"); > > else > > buf += sysfs_emit(buf, " "); > > > > Shame there's no sysfs_emitc, but there you go. > > I think what's there is simple. Again, you're wrong. > And your suggested code doesn't work. > sysfs_emit is used for single emits. > sysfs_emit_at is used for multiple emits. Oh, ugh, sysfs_emit() should be able to work on a buffer that isn't page aligned. Greg, how about this? +++ b/fs/sysfs/file.c @@ -722,13 +722,13 @@ int sysfs_emit(char *buf, const char *fmt, ...) { va_list args; int len; + int start = offset_in_page(buf); - if (WARN(!buf || offset_in_page(buf), - "invalid sysfs_emit: buf:%p\n", buf)) + if (WARN(!buf, "invalid sysfs_emit: buf:%p\n", buf)) return 0; va_start(args, fmt); - len = vscnprintf(buf, PAGE_SIZE, fmt, args); + len = vscnprintf(buf, PAGE_SIZE - start, fmt, args); va_end(args); return len;