Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4252552ybc; Fri, 15 Nov 2019 01:21:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzou5PTO5KJbDoZHc0QFBxPSmqjh+fz87RpPDm+1iKJuTaV6apGyoZbf/SM5GVlb+fv5Nl0 X-Received: by 2002:a17:906:8591:: with SMTP id v17mr12635176ejx.185.1573809695881; Fri, 15 Nov 2019 01:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573809695; cv=none; d=google.com; s=arc-20160816; b=q8PqZsafy5QIHoXXuZegijyhsOXkgnZY8+NNiR79h9/11jH3nzjlX8I/NQeMdmbrQw iQC1wvCpGPrNzhQ1nymzK9R+x2xVJ/8IeZVMsYX6oQ7sBOWyXmwFU2sfowYUrSlfaZVG zSd/KGLVx9L84JqSq3CvyjyjkIpCIEPv6VKNQuiPx6nU6m5BH1PewgbN44nbmj5ps5XN vqok3VZHA+TN0S7BOobQV+r6cfY4cukIRfwN/tEU44+a7r3aHkGPXVu3jhnmGCGffZyP Z6tmzOWz4QSYysyJVZndUHtrO7+RcL4KpiE2tygjC4Bh1WmX7Od3ucrsqOgr6WDsCHpB H6DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CaVJL0m4rVC3kIgt7PaU/sZ/HckuS6iVscw9ZZiEBBw=; b=ZmkrGZKL21GL2Lnff5EHl+zio1dRnYgB67OtTzEoNaE1ifDEzF6ZzrNqqoLTwdNLfZ mct65yjRZUFvjNXU9b1SO5dramKGlwIk3ilH4of9aTb/hYk50F1Rca6970/oW/kaTN5y WxYZdg8n+rdB5rBmvafG0HhEh9BrXCr76krP1nS7EB7wtIqg8M8HERXLxi//MIj+T+X2 vW+yMhbUhHenvto6PG6stu0i+Opu2ZB0kvHRaofxb8FeEFBnFRQIV01YNSDdlElWiuDh Gm3glr2ZFmEZUpoZWr7fmE6LJrbBApsykfdxgjOXdBPK2VGM8V9Et4ys1DURKuq5jNJX 2Ugg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KJsystCX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id op11si5214725ejb.107.2019.11.15.01.21.11; Fri, 15 Nov 2019 01:21:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KJsystCX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbfKOJT4 (ORCPT + 99 others); Fri, 15 Nov 2019 04:19:56 -0500 Received: from merlin.infradead.org ([205.233.59.134]:58364 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbfKOJT4 (ORCPT ); Fri, 15 Nov 2019 04:19:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CaVJL0m4rVC3kIgt7PaU/sZ/HckuS6iVscw9ZZiEBBw=; b=KJsystCX+eKUhlSxbNUCd/mmx HMGb8vM5Z2ldYimeZVR2muQrcWpB98iMQ3W8DOuva+pWvm3DyHlxsfgcDGnuWf6YNF1WCAOIRZxhA QZRk3E6WFHZdIeGs0Z3ehNZe6wobo5EqeWNsI2uL4aj3n6V3ftzYbN6ZmV/WeKTW4hkxTse6htBsA VwBaHuSgw6tdp2CfOdqTzRq9eYjJ4KPbRyV46kGhGPqU3m1z1E6PCa8/Mfls2Gfcr6MFW5d1QFO0g 3L9E5+FY/ccD0Vh7yYkvNiCjOeeB8puQmXkkovj8vpqdW3PLzy4KVi2kL7e7aqhlz+SGTq4ZGdXvt Bi8iVWMkg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iVXlc-0005KW-EY; Fri, 15 Nov 2019 09:19:48 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3C4A2303D9F; Fri, 15 Nov 2019 10:18:37 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4929429E4EBB1; Fri, 15 Nov 2019 10:19:45 +0100 (CET) Date: Fri, 15 Nov 2019 10:19:45 +0100 From: Peter Zijlstra To: Shile Zhang Cc: Josh Poimboeuf , Masahiro Yamada , Michal Marek , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [RFC PATCH v3 6/7] scripts/sorttable: Add ORC unwind tables sort concurrently Message-ID: <20191115091945.GT4114@hirez.programming.kicks-ass.net> References: <20191115064750.47888-1-shile.zhang@linux.alibaba.com> <20191115064750.47888-7-shile.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191115064750.47888-7-shile.zhang@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 15, 2019 at 02:47:49PM +0800, Shile Zhang wrote: > @@ -141,21 +306,44 @@ static int do_sort(Elf_Ehdr *ehdr, > if (r(&s->sh_type) == SHT_SYMTAB_SHNDX) > symtab_shndx = (Elf32_Word *)((const char *)ehdr + > _r(&s->sh_offset)); > - } > > +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED) > + /* locate the ORC unwind tables */ > + if (!strcmp(secstrings + idx, ".orc_unwind_ip")) { > + orctable.orc_ip_size = s->sh_size; > + g_orc_ip_table = (int *)((void *)ehdr + > + s->sh_offset); > + } > + if (!strcmp(secstrings + idx, ".orc_unwind")) { > + orctable.orc_size = s->sh_size; > + g_orc_table = (struct orc_entry *)((void *)ehdr + > + s->sh_offset); > + } > +#endif > + } /* for loop */ > + > +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED) Maybe something like: if (g_orc_table && g_orc_ip_table) { if (pthread_create(...)) ... } else if (g_orc_table || g_orc_up_table) { fprintf(stderr, "incomplete ORC tables...\n"); } > + /* create thread to sort ORC unwind tables concurrently */ > + if (pthread_create(&orc_sort_thread, NULL, sort_orctable, &orctable)) { > + fprintf(stderr, > + "pthread_create orc_sort_thread failed '%s': %s\n", > + strerror(errno), fname); > + goto out; > + } > +#endif > if (!extab_sec) { > fprintf(stderr, "no __ex_table in file: %s\n", fname); > - return -1; > + goto out; > } > > if (!symtab_sec) { > fprintf(stderr, "no .symtab in file: %s\n", fname); > - return -1; > + goto out; > } > > if (!strtab_sec) { > fprintf(stderr, "no .strtab in file: %s\n", fname); > - return -1; > + goto out; > } > > extab_image = (void *)ehdr + _r(&extab_sec->sh_offset); > @@ -192,7 +380,7 @@ static int do_sort(Elf_Ehdr *ehdr, > fprintf(stderr, > "no main_extable_sort_needed symbol in file: %s\n", > fname); > - return -1; > + goto out; > } > > sort_needed_sec = &shdr[get_secindex(r2(&sym->st_shndx), > @@ -205,6 +393,20 @@ static int do_sort(Elf_Ehdr *ehdr, > > /* extable has been sorted, clear the flag */ > w(0, sort_needed_loc); > + rc = 0; > > - return 0; > +out: > +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED) > + { /* to avoid gcc warning about declaration */ > + void *retval = NULL; and then here: if (orc_sort_thread) { void *retval = NULL; pthread_join(...); ... } > + > + /* wait for ORC tables sort done */ > + pthread_join(orc_sort_thread, &retval); > + if (retval) { > + fprintf(stderr, "%s in file: %s\n", (char *)retval, fname); > + rc = -1; > + } > + } > +#endif > + return rc; > }