From patchwork Mon Mar 27 11:56:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 9646461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B2A5602D6 for ; Mon, 27 Mar 2017 11:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D07C1FF87 for ; Mon, 27 Mar 2017 11:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FB13204C2; Mon, 27 Mar 2017 11:57:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C588D1FF87 for ; Mon, 27 Mar 2017 11:57:13 +0000 (UTC) Received: from localhost ([::1]:46165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csTGq-0002wE-RL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Mar 2017 07:57:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csTGI-0002vs-R7 for qemu-devel@nongnu.org; Mon, 27 Mar 2017 07:56:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csTGB-0007zV-Vx for qemu-devel@nongnu.org; Mon, 27 Mar 2017 07:56:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45778 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csTGB-0007yS-P8 for qemu-devel@nongnu.org; Mon, 27 Mar 2017 07:56:31 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2RBrdji004646 for ; Mon, 27 Mar 2017 07:56:30 -0400 Received: from e28smtp01.in.ibm.com (e28smtp01.in.ibm.com [125.16.236.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 29dnwu1qup-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Mar 2017 07:56:30 -0400 Received: from localhost by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Mar 2017 17:26:26 +0530 Received: from d28relay04.in.ibm.com (9.184.220.61) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Mar 2017 17:26:25 +0530 Received: from d28av08.in.ibm.com (d28av08.in.ibm.com [9.184.220.148]) by d28relay04.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2RBuPVk15597804 for ; Mon, 27 Mar 2017 17:26:25 +0530 Received: from d28av08.in.ibm.com (localhost [127.0.0.1]) by d28av08.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2RBuOXp008184 for ; Mon, 27 Mar 2017 17:26:25 +0530 Received: from abhimanyu.vnet.linux.ibm.com (abhimanyu.in.ibm.com [9.124.35.247]) by d28av08.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2RBuME8008181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 27 Mar 2017 17:26:24 +0530 From: Nikunj A Dadhania To: Alex =?utf-8?Q?Benn=C3=A9e?= In-Reply-To: <877f3fx7p0.fsf@linaro.org> References: <1472935202-3342-1-git-send-email-rth@twiddle.net> <1472935202-3342-14-git-send-email-rth@twiddle.net> <87vay1w7p8.fsf@linaro.org> <87efxn9e2f.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> <877f3fx7p0.fsf@linaro.org> User-Agent: Notmuch/0.23.5 (https://notmuchmail.org) Emacs/25.1.1 (x86_64-redhat-linux-gnu) Date: Mon, 27 Mar 2017 17:26:22 +0530 MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17032711-7323-0000-0000-000000E23F0C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032711-7324-0000-0000-000002875870 Message-Id: <877f3bq6ft.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-27_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703270103 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: Re: [Qemu-devel] [PATCH v3 13/34] tcg: Add atomic helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Alex Bennée writes: > Nikunj A Dadhania writes: > >> Richard Henderson writes: >> >>> On 09/12/2016 06:47 AM, Alex Bennée wrote: >>>>> > + /* Notice an IO access, or a notdirty page. */ >>>>> > + if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { >>>>> > + /* There's really nothing that can be done to >>>>> > + support this apart from stop-the-world. */ >>>>> > + goto stop_the_world; >>>> We are also triggering on TLB_NOTDIRTY here in the case where a >>>> conditional write is the first write to a page. I don't know if a >>>> stop_the_world is required at this point but we will need to ensure we >>>> clear bits as notdirty_mem_write() does. >>>> >>> >>> You're quite right that we could probably special-case TLB_NOTDIRTY here such >>> that (1) we needn't leave the cpu loop, and (2) needn't utilize the actual >>> "write" part of notdirty_mem_write; just set the bits then fall through to the >>> actual atomic instruction below. >> >> I do hit this case with ppc64, where I see that its the first write to >> the page and it exits from this every time, causing the kernel to print >> soft-lockups. >> >> Can we add the special case here for NOTDIRTY and set the page as dirty >> and return successfully? > > Does the atomic step fall-back not work for you? Looked further and I do see that EXCP_ATOMIC does get executed in qemu_tcg_cpu_thread_fn(), but I am not sure what is going wrong there. Following snippet fixes the issue for me: Regards Nikunj diff --git a/cputlb.c b/cputlb.c index f5d056c..743776a 100644 --- a/cputlb.c +++ b/cputlb.c @@ -930,7 +930,13 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, tlb_addr = tlbe->addr_write; } - /* Notice an IO access, or a notdirty page. */ + /* Check notdirty */ + if (unlikely(tlb_addr & TLB_NOTDIRTY)) { + tlb_set_dirty(ENV_GET_CPU(env), addr); + tlb_addr = tlb_addr & ~TLB_NOTDIRTY; + } + + /* Notice an IO access */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { /* There's really nothing that can be done to support this apart from stop-the-world. */