Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp19077ybm; Tue, 26 May 2020 09:42:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6vg6W72LSS9pWj/Zy4TWkws9+fs3jNHcoD492KzL/F7N2UyY4KDmOymkO0mrwLPApMxVH X-Received: by 2002:a17:906:509:: with SMTP id j9mr322129eja.341.1590511326684; Tue, 26 May 2020 09:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590511326; cv=none; d=google.com; s=arc-20160816; b=cZ+gUY80OpdW12uEFyW6wbp2tJp7bU072Npa94tP1YkRUaDm2kYEjhC5sx8KnsPVxB wsc9Q/gWVyGN7z3XgyApu1+tQ1uZ9FV8kMROgIL3umydWmBwEiTkcaHRqmu7xFmu/b66 7vWhfJXrQu6PaTDTc+PurfP9PuWvsfOY8qXi2BYP3gI9y3YddBK8180mBCzeSYOO3Vez eG5yn91b+zMFNiVPVbdhVjbxwsyYFwVxWRXo8lpxIS5qPimUeg/I3A9nkUMK5gS0Cx0W h6fIk6KaUEFTvB9IrFiqVCclF+Z9i3crGDvTtMj04Bzf64d7kSdfxJTIgd/Tsjk6k1jp 1jGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=vfYtvQDrmGAh2kQwFWXxk+6FPkudgejWVEqo4FRuZBo=; b=QrT8QPdVRzEJnJjwiBR+orPVkzT4Cpgn6IO7j/XhiplegehdUotjjac/BGC3JG6zqv 3AD9Zq0chBf/NEjiV3UKH/H4foi83MuhEOCwAV2bfnuYhP3/F9Z4QWW6+XrbIvXKlOPX aZF0FC2KLHeJj9GwN+fll0m4h6kfVXL4Amc45pBYwbXoIkghNt7BGB8oSfGaCC9lNIOd bru2WGTgMIWXYj0mY3qLraElEnGe1BenoKLdQogZo6+AglGFtZbHcfpI8GW69tgii73K PNu87w7rknkOqeLXkMI2+jDlpKmr1LZtdc1jOoRNYliF9a/00I6bmjvrEOlggcLccHO6 sHBg== ARC-Authentication-Results: i=1; mx.google.com; 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 uz8si216320ejb.67.2020.05.26.09.41.42; Tue, 26 May 2020 09:42:06 -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; 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 S1729681AbgEZQju (ORCPT + 99 others); Tue, 26 May 2020 12:39:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:40992 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgEZQju (ORCPT ); Tue, 26 May 2020 12:39:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4FAADAD18; Tue, 26 May 2020 16:39:51 +0000 (UTC) Date: Tue, 26 May 2020 18:39:47 +0200 (CEST) From: Miroslav Benes To: Josh Poimboeuf cc: Randy Dunlap , Stephen Rothwell , Linux Next Mailing List , Linux Kernel Mailing List , Peter Zijlstra , mjambor@suse.cz, mliska@suse.cz, pmladek@suse.cz, live-patching@vger.kernel.org Subject: Re: linux-next: Tree for May 21 (objtool warnings) In-Reply-To: <20200526140113.ppjywpx7uir3vrlj@treble> Message-ID: References: <20200522001209.07c19400@canb.auug.org.au> <22332d9b-5e9f-5474-adac-9b3e39861aee@infradead.org> <20200526140113.ppjywpx7uir3vrlj@treble> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 May 2020, Josh Poimboeuf wrote: > On Mon, May 25, 2020 at 01:07:27PM +0200, Miroslav Benes wrote: > > > I'll try to find out which optimization does this, because it is a > > > slightly different scenario than hiding __noreturn from the callees. > > > Probably -fno-ipa-pure-const again. > > > > And it is indeed -fno-ipa-pure-const again. > > It still seems odd to me that GCC's dead end detection seems to break > with -fno-ipa-pure-const. Do you know if these issues can be fixed on > the GCC side? It is odd. I asked Martin and Martin about that yesterday (CCed). It could be possible to enable just noreturn propagation for -flive-patching if I understood correctly. The attribute would need to be preserved in a patched function then, but that should be manageable. Marking functions as __noreturn is one thing (I think it is useful on its own as mentioned in the older thread about -flive-patching), but __always_inline solution in this case is really arbitrary. I don't like this neverending "battle" with compilers much, so it would be nice to have some kind of generic solution (and I currently have no idea about that). Of course, declaring -flive-patching a failed experiment is an option if there is not a better way to deal with a dead end detection either in GCC or in objtool. I would not like it, but you're right that if there are more and more problems like this appearing, we'll have to deal with maintainers all over the place and ask them to maintain odd fixes just for the sake of -flive-patching. I don't know what the current numbers are though. We'd have to approach the problem of GCC optimizations from a different angle. Petr CCed (we talked about it yesterday as well). But first, let's try to find a way with -flive-patching. Reduced test case follows (courtesty of Martin Liska): $ cat open.i int global; void break_deleg_wait() { asm(".byte 15, 0x0b"); __builtin_unreachable(); } void chmod_common_delegated_inode(int arg) { retry_deleg: if (arg) break_deleg_wait(global); else return; goto retry_deleg; } $ gcc open.i -c -Os -fno-omit-frame-pointer -fno-ipa-pure-const && ./tools/objtool/objtool check open.o open.o: warning: objtool: chmod_common_delegated_inode()+0x18: unreachable instruction $ gcc open.i -c -Os -fno-omit-frame-pointer && ./tools/objtool/objtool check open.o [OK] --- So it is a similar problem. There is no noreturn attribute anywhere (nothing to propagate from a caller to a callee). Here, the information about an unreachable code is not propagated to the caller (chmod_common_delegated_inode()). Martins, would it be possible to extend -flive-patching to deal with this? Miroslav