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 570D1C433DF for ; Sun, 23 Aug 2020 15:54:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 12BA52072D for ; Sun, 23 Aug 2020 15:54:58 +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="mdg1xSht" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12BA52072D 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 908226B0002; Sun, 23 Aug 2020 11:54:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B7D26B0005; Sun, 23 Aug 2020 11:54:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 757BD6B0006; Sun, 23 Aug 2020 11:54:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 5ADE26B0002 for ; Sun, 23 Aug 2020 11:54:58 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1E8461EF1 for ; Sun, 23 Aug 2020 15:54:58 +0000 (UTC) X-FDA: 77182281876.10.game02_35174852704b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id E585E16A069 for ; Sun, 23 Aug 2020 15:54:57 +0000 (UTC) X-HE-Tag: game02_35174852704b X-Filterd-Recvd-Size: 3456 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Sun, 23 Aug 2020 15:54:57 +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-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 In-Reply-To: <20200823152130.GA17456@casper.infradead.org> X-Rspamd-Queue-Id: E585E16A069 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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, 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 =3D offsetof(struct hugetlb_cgroup, events_file= [idx]), > > >> + cft->file_offset =3D offsetof(struct hugetlb_cgroup, events_file= [idx]); > > >> cft->flags =3D CFTYPE_NOT_ON_ROOT; > >=20 > > 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. >=20 > That's not how the comma operator works. >=20 > It will evaluate offsetof(struct hugetlb_cgroup, events_file[idx]) and > then discard the result. Since it has no side-effects, this is effecti= vely > doing: >=20 > cft->file_offset =3D cft->flags =3D 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 =3D 1, a->y =3D 0; } void h(struct a *a) { a->x =3D (1, a->y =3D 0); } test.c: In function =E2=80=98h=E2=80=99: test.c:12:12: warning: left-hand operand of comma expression has no effec= t [-Wunused-value] 12 | a->x =3D (1, | ^ 0000000000000000 : 0: 48 c7 07 01 00 00 00 movq $0x1,(%rdi) 7: c3 retq =20 8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) f: 00=20 0000000000000010 : 10: 48 c7 07 00 00 00 00 movq $0x0,(%rdi) 17: c3 retq =20 So there's no bug here! It's just confusing, so should be fixed. (I think Andrew was confused too ;-)