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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 CE508C433FE for ; Mon, 20 Sep 2021 17:26:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BE1D632DA for ; Mon, 20 Sep 2021 17:26:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8BE1D632DA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191051.340946 (Exim 4.92) (envelope-from ) id 1mSN39-00051d-RE; Mon, 20 Sep 2021 17:25:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191051.340946; Mon, 20 Sep 2021 17:25:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSN39-0004zs-Ly; Mon, 20 Sep 2021 17:25:51 +0000 Received: by outflank-mailman (input) for mailman id 191051; Mon, 20 Sep 2021 17:25:50 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSN38-0003cq-Cg for xen-devel@lists.xenproject.org; Mon, 20 Sep 2021 17:25:50 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c5e97c3b-1a37-11ec-b87a-12813bfff9fa; Mon, 20 Sep 2021 17:25:40 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c5e97c3b-1a37-11ec-b87a-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1632158740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=op3mN7Ssn2+qHvMncFrr9eY7JKq/qdFKvePUbUZAdVE=; b=RcVOOoaze2uwR7P9cXIuOh6dtW2+TpF9fVjIuYhA13ckgTV3TFdk/sUY LEXbWRfFhiKkFy+RQMRQpBZBVp0g0urKzrvln7NnKC0Mz68L8w3XmVnIV AN5yiovRy7qCvhwf0Z7lCZxWwIV/mPGfxhxgVNSTkqJDrAlEvl4iCmi2/ w=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: eDVWBXpWkoIOoo1AZVM4liBpfZcmugDKNRYzyrxPPYjrE3mqsirArDaUXgCfQrbvgBVttQ+g0L cfkXCAwNbQllMw4iSPZrM2oKdbiBYaZhueWW5XOqphEN3V0+YbuWu6f5ZdO5ymNNC17D4L8WIe gwJWeHXsDR6DdWnMJJmXekeID0oLhgdmFtHTEH5AcbADiI6w0AdqMLkOTcLs5Jr+kYJo8h56jM y6DLYBwuuPnM4SpxTq6x+ufRoWFdcE27uXuhSf1r08j475mY/knmRA1WrDJVWtq+g5L1IohsmV ThmAn1z6meN8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yMCl/OIKDgdfqqIBueim7AoHON9wM2LWaJ39zu3+HXAbIllY cvLGSpSJS9CVMyLMwZat89CiOR2l0jSNEv4RIzhzgTP7FZtTCfOEt843K+1Rrlhtsus+VyNm /4Gbpfi40gPAYXWP3iMmaZOfA9iEJTOLc2vwyChXrXYeVQO9aBII6K5/I7NjKQ/zvwJyb+Xr i/iMqKaoXKm7UD6xcyxQigLQNvSsVxX9hrX5AQgYgSl3WYNe4Gq4PtNfpc7Z+B/pudi0eR1X 78OfMDZWqZDTTHO+jI8a5jhrdM9KET31FzWZyf1MiIie5NARhDS/oO2dAXY6yRTXDG8stEzo uP821qDE4YDXQlrEO3fdOmrkwGqpXEYle8rBxnIL9BfdV/C6o9vLyCt3PY7L9tVcUfIxyeA1 hbQChAd/LGfr4gw+djPpKaFs4b2TLcuQhsERzHWtO/kOzPb82yvxZ57fNyJJT2NBnnp/KiCZ PlOy62uOvMwg1sX4ZF3FKxmzPxi6oK39aNa1AltAF7Cc0+vVuF7OnCD0MRC6v9Ny7tetVfkU 06D4IAHa7CAOcejG18NPgs1KO+E0KhMyDXV6P00JmT85TN2o+XbARkDYUHUhXwPNqZxPaMk3 fwl6Zwf5AGIgxY3NsqL03JP/GOWI31cC6gqu/n22mMwZtbHHr2aXaHhNw== IronPort-HdrOrdr: A9a23:fepU9qq6Y6YRGtz1OIBx+ngaV5opeYIsimQD101hICG8cqSj+f xG/c5rrCMc5wxwZJhNo7y90ey7MBbhHP1OkO8s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpM BdmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.85,308,1624334400"; d="scan'208";a="54938585" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH v2 09/12] xen/trace: Minor code cleanup Date: Mon, 20 Sep 2021 18:25:26 +0100 Message-ID: <20210920172529.24932-10-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210920172529.24932-1-andrew.cooper3@citrix.com> References: <20210920172529.24932-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain * Delete trailing whitespace * Replace an opencoded DIV_ROUND_UP() * Drop bogus smp_rmb() - spin_lock_irqsave() has full smp_mb() semantics. Signed-off-by: Andrew Cooper --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli --- xen/common/trace.c | 37 +++++++++++++++---------------------- xen/include/asm-x86/hvm/trace.h | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index 4297ff505fb9..41a3c170446b 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -75,10 +75,6 @@ static cpumask_t tb_cpu_mask; /* which tracing events are enabled */ static u32 tb_event_mask = TRC_ALL; -/* Return the number of elements _type necessary to store at least _x bytes of data - * i.e., sizeof(_type) * ans >= _x. */ -#define fit_to_type(_type, _x) (((_x)+sizeof(_type)-1) / sizeof(_type)) - static int cpu_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -96,8 +92,8 @@ static struct notifier_block cpu_nfb = { static uint32_t calc_tinfo_first_offset(void) { - int offset_in_bytes = offsetof(struct t_info, mfn_offset[NR_CPUS]); - return fit_to_type(uint32_t, offset_in_bytes); + return DIV_ROUND_UP(offsetof(struct t_info, mfn_offset[NR_CPUS]), + sizeof(uint32_t)); } /** @@ -148,7 +144,7 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset) pages = max_pages; } - /* + /* * NB this calculation is correct, because t_info_first_offset is * in words, not bytes */ @@ -167,7 +163,7 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset) * trace buffers. The trace buffers are then available for debugging use, via * the %TRACE_xD macros exported in . * - * This function may also be called later when enabling trace buffers + * This function may also be called later when enabling trace buffers * via the SET_SIZE hypercall. */ static int alloc_trace_bufs(unsigned int pages) @@ -401,7 +397,7 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc) break; case XEN_SYSCTL_TBUFOP_enable: /* Enable trace buffers. Check buffers are already allocated. */ - if ( opt_tbuf_size == 0 ) + if ( opt_tbuf_size == 0 ) rc = -EINVAL; else tb_init_done = 1; @@ -438,7 +434,7 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc) return rc; } -static inline unsigned int calc_rec_size(bool_t cycles, unsigned int extra) +static inline unsigned int calc_rec_size(bool_t cycles, unsigned int extra) { unsigned int rec_size = 4; @@ -597,7 +593,7 @@ static inline void __insert_record(struct t_buf *buf, rec->u.cycles.cycles_lo = (uint32_t)tsc; rec->u.cycles.cycles_hi = (uint32_t)(tsc >> 32); dst = rec->u.cycles.extra_u32; - } + } if ( extra_data && extra ) memcpy(dst, extra_data, extra); @@ -717,9 +713,6 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, if ( !cpumask_test_cpu(smp_processor_id(), &tb_cpu_mask) ) return; - /* Read tb_init_done /before/ t_bufs. */ - smp_rmb(); - spin_lock_irqsave(&this_cpu(t_lock), flags); buf = this_cpu(t_bufs); @@ -735,14 +728,14 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, /* Calculate the record size */ rec_size = calc_rec_size(cycles, extra); - + /* How many bytes are available in the buffer? */ bytes_to_tail = calc_bytes_avail(buf); - + /* How many bytes until the next wrap-around? */ bytes_to_wrap = calc_bytes_to_wrap(buf); - - /* + + /* * Calculate expected total size to commit this record by * doing a dry-run. */ @@ -756,7 +749,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, { total_size += bytes_to_wrap; bytes_to_wrap = data_size; - } + } total_size += LOST_REC_SIZE; bytes_to_wrap -= LOST_REC_SIZE; @@ -768,7 +761,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, if ( rec_size > bytes_to_wrap ) { total_size += bytes_to_wrap; - } + } total_size += rec_size; /* Do we have enough space for everything? */ @@ -781,7 +774,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, } /* - * Now, actually write information + * Now, actually write information */ bytes_to_wrap = calc_bytes_to_wrap(buf); @@ -791,7 +784,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, { insert_wrap_record(buf, LOST_REC_SIZE); bytes_to_wrap = data_size; - } + } insert_lost_records(buf); bytes_to_wrap -= LOST_REC_SIZE; diff --git a/xen/include/asm-x86/hvm/trace.h b/xen/include/asm-x86/hvm/trace.h index 145b59f6ac65..696e42eb9499 100644 --- a/xen/include/asm-x86/hvm/trace.h +++ b/xen/include/asm-x86/hvm/trace.h @@ -52,7 +52,7 @@ #define DO_TRC_HVM_CLTS DEFAULT_HVM_MISC #define DO_TRC_HVM_LMSW DEFAULT_HVM_MISC #define DO_TRC_HVM_LMSW64 DEFAULT_HVM_MISC -#define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC +#define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP_DEBUG DEFAULT_HVM_MISC #define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC -- 2.11.0