From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AEC713858C20; Mon, 30 Jan 2023 07:09:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEC713858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675062588; bh=YxTBmwIGTmnl+EV6R+cuWLAPDLayXnuoIur6wSnEMJg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pI3csx1wB5ODpapkqRI2nQlmqNBr70T5LPE+vUrFZ7vKPAqRDeex/dgE+RTeFoT7C 5X0E96alLBSR8zPVU1aF7A4kly1Z8LjhH68ZEsqmCT8RU1ZpKOykTRMMouZf4riDbf vuI5+rGTnWnSvh0x2v0HWXFz96QXikhB7yrdbzQo= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108552] Linux i386 kernel 5.14 memory corruption for pre_compound_page() when gcov is enabled Date: Mon, 30 Jan 2023 07:09:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108552 --- Comment #42 from Richard Biener --- (In reply to Jakub Jelinek from comment #40) > (In reply to Jan Hubicka from comment #39) > > I was wonering if we should not provide flag to turn all counts > > volatile. That way we will still have race conditions on their updates > > (and it would be chepaer than atomic) but we won't run into such wrong > > code issues nor large profile mismatches. >=20 > Yes, see above. Or a mode in which we would just avoid hoisting and sink= ing > the gcov vars but keep them non-volatile. Or both. > But I guess it would be nice to get Vlad's patch into trunk and release > branches for now (perhaps with an extra check for startswith "__gcov" on > DECL_NAME, so that we don't do it for the Fortran tokens). >=20 > As for the patch, just small nits, I think get_base_address returns always > non-NULL, so it could be > if (tree expr =3D MEM_EXPR (res)) > { > expr =3D get_base_address (expr); > if (VAR_P (expr) > && DECL_NONALIASED (expr) > && DECL_NAME (expr)) > { > const char *name =3D IDENTIFIER_POINTER (DECL_NAME (expr)); > /* Don't reread coverage counters from memory, if single > update model is used in threaded code, other threads > could change the counters concurrently. See PR108552. = */ > if (startswith (name, "__gcov")) > return x; > } > } Note that this isn't exactly reliable but a heuristic workaround since MEM_EXPRs are optional and dropping them is valid (and done in some places). I think if we want to avoid doing optimizations on gcov counters we should make them volatile. I suppose kernel folks would have a way to assess any "catastrophic consequences" on optimization? (I have a hard time imagining them, sure that RMW will not allow add with memory operand, but that's it?)=