Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1607963pxa; Sun, 23 Aug 2020 09:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRjcR/6iTWZTbOrbtPiHcbeiUdgcJHfcUTWr3/BPFACTCB9/T73THV4sHKmn4GyBdhhVcw X-Received: by 2002:a50:ee92:: with SMTP id f18mr1807601edr.191.1598199415098; Sun, 23 Aug 2020 09:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598199415; cv=none; d=google.com; s=arc-20160816; b=Q0T6lF2DZ3unzse+YXXjXRnKrM08i3Km0HnMwpA4XCWRX/G3Gn96Fgy66APhZMV15X UFDI0Owg10BmHkTyN2zILkexaxcNjRQvBngCUCCPzSh+N85Y3PFkXEmay87A2AtbGgrr mRonnL+kn/71kCMADDrchikBCicezF0iuGG7lPR3C9NIHe1coRWcP6qWapwhvT+fEP6u hIxGnwyN83h3JrlC5tT1QfFA6/BbGhomadJlfA6Y30muNp7FeYmqds7MYoIFUwoFAxdO 20IAG89bgin7/NGGAyJp7zossjE1Zb9w16+IyEafeS8t18Ss6E1jo+lu7pyHLfC53NFT KGBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gTFW7gfK1pw0y0A6L2wm8p78fu8cvj8YkHvYnky0j6E=; b=DtapRRWL0rQ3nouKPQx7f2nuuQB1yKqvaPBP93zlAcawkCrO0vdpczDoC27RLilFSV vzWSbNT/J5KDJK23hODr/X4C4X/eChZbmpDOSjIagRZ+liHW4PycnTTLkYAjEa7/KB/a mbKNsF0L2U+JHXLoE1BsNOhfTZmzqImfJ+WQyMkULDObA0hf4vk0dK+9bVXU+I1MrTvr WWubRe0JWc7OoGDxjQZtRoo0Rz7BZ/TE2oXRMk+yegsPHvkplbSs35ferhAFbxLjdj86 3+ynwnsguRKh8viVcekTsiKJQoc8mSgzo8VsnUZdpydBQoNEoAk7u17Nr3VWx5YKP1Qa nTOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=mdg1xSht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si3371555edv.154.2020.08.23.09.16.31; Sun, 23 Aug 2020 09:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=mdg1xSht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727968AbgHWPzA (ORCPT + 99 others); Sun, 23 Aug 2020 11:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgHWPzA (ORCPT ); Sun, 23 Aug 2020 11:55:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D492C061573 for ; Sun, 23 Aug 2020 08:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=gTFW7gfK1pw0y0A6L2wm8p78fu8cvj8YkHvYnky0j6E=; b=mdg1xShthE41AFop+/agpm3Y+m yqYERkc00Itm4p/ciW2TzUNTiZVB1DnXfxkDgvg5CDyna6DgS4WE1rro3Xv3YV1ZYALm3BFUxwnL/ K5OBQ0k1DW+Yu5WrNOXIsIYCUGjWhitQ32N1wipvGUhfD8LtcbdMGy8+st35F7FyeE19+kuvxNnqh zGi06Nam18XtyjPY8XYiXZd2S28nCFWk7F8EUdtCih+A2Hud8TdrJVG9g8kpLgz0uHatlHIjRRfdL jcEuKYIl8f382tCcOqitNCD+FolBarHIAN1wVIdCNbSYO5yAaMlk6cS9ETHCbtYRDomgBErDwETBV 3DByR58g==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9sKb-0000O8-2f; Sun, 23 Aug 2020 15:54:53 +0000 Date: Sun, 23 Aug 2020 16:54:53 +0100 From: Matthew Wilcox To: Giuseppe Scrivano Cc: Andrew Morton , Xu Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tejun Heo Subject: Re: [PATCH] hugetlb_cgroup: convert comma to semicolon Message-ID: <20200823155453.GB17456@casper.infradead.org> References: <20200818064333.21759-1-vulab@iscas.ac.cn> <20200818184036.d6c479446b2c3b231d1e3bff@linux-foundation.org> <87eeo32gto.fsf@redhat.com> <20200823152130.GA17456@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200823152130.GA17456@casper.infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 23, 2020 at 04:21:30PM +0100, Matthew Wilcox wrote: > On Wed, Aug 19, 2020 at 10:14:11AM +0200, Giuseppe Scrivano wrote: > > >> - cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]), > > >> + cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]); > > >> cft->flags = CFTYPE_NOT_ON_ROOT; > > > > I think in this case having two expressions as part of the same > > statement is equivalent to having two separate statements. Both > > cft->file_offset and cft->flags get the expected value. > > That's not how the comma operator works. > > It will evaluate offsetof(struct hugetlb_cgroup, events_file[idx]) and > then discard the result. Since it has no side-effects, this is effectively > doing: > > cft->file_offset = cft->flags = CFTYPE_NOT_ON_ROOT; _oh_. I tested this. I'm wrong because the comma operator is at lower precedence than assignment. Testcase: struct a { int x; int y; }; void g(struct a *a) { a->x = 1, a->y = 0; } void h(struct a *a) { a->x = (1, a->y = 0); } test.c: In function ‘h’: test.c:12:12: warning: left-hand operand of comma expression has no effect [-Wunused-value] 12 | a->x = (1, | ^ 0000000000000000 : 0: 48 c7 07 01 00 00 00 movq $0x1,(%rdi) 7: c3 retq 8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) f: 00 0000000000000010 : 10: 48 c7 07 00 00 00 00 movq $0x0,(%rdi) 17: c3 retq So there's no bug here! It's just confusing, so should be fixed. (I think Andrew was confused too ;-)