linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Rui Teng <rui.teng@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, paulus@samba.org
Subject: Re: [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c
Date: Thu, 01 Sep 2016 12:46:40 -0300	[thread overview]
Message-ID: <17335881.L5K12VaGEe@hactar> (raw)
In-Reply-To: <1472183410-18522-1-git-send-email-rui.teng@linux.vnet.ibm.com>

Am Freitag, 26 August 2016, 11:50:10 schrieb Rui Teng:
> The same logic appears twice and should probably be pulled out into a
> function.
> 
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
> ---
>  arch/powerpc/mm/hash_utils_64.c | 45
> +++++++++++++++++------------------------ 1 file changed, 19
> insertions(+), 26 deletions(-)
> 
> diff --git a/arch/powerpc/mm/hash_utils_64.c
> b/arch/powerpc/mm/hash_utils_64.c index 0821556..69ef702 100644
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -1460,6 +1460,23 @@ out_exit:
>  	local_irq_restore(flags);
>  }
> 
> +/*
> + * Transactions are not aborted by tlbiel, only tlbie.
> + * Without, syncing a page back to a block device w/ PIO could pick up
> + * transactional data (bad!) so we force an abort here.  Before the
> + * sync the page will be made read-only, which will flush_hash_page.
> + * BIG ISSUE here: if the kernel uses a page from userspace without
> + * unmapping it first, it may see the speculated version.
> + */
> +void local_tm_abort(int local)
> +{
> +	if (local && cpu_has_feature(CPU_FTR_TM) && current->thread.regs &&
> +		MSR_TM_ACTIVE(current->thread.regs->msr)) {
> +		tm_enable();
> +		tm_abort(TM_CAUSE_TLBI);
> +	}
> +}
> +

Since local_tm_abort is only used in this file, it should be static.

Also, since both places calling it are guarded by 
CONFIG_PPC_TRANSACTIONAL_MEM, wouldn't it be cleaner if the #ifdef was here 
instead and the #else block defined an empty static inline function? Then 
the call sites wouldn't need to be guarded.

-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

  reply	other threads:[~2016-09-01 15:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26  3:50 [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c Rui Teng
2016-09-01 15:46 ` Thiago Jung Bauermann [this message]
2016-09-02  2:52   ` Rui Teng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17335881.L5K12VaGEe@hactar \
    --to=bauerman@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=rui.teng@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).