Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp299714ybi; Thu, 1 Aug 2019 19:22:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXh/jxpe9XzPKmnw1sJec0kTzoQmwzb6rGX0Hu/4KR7RIvqdGSpmICr17Jet1so/8lZpHZ X-Received: by 2002:aa7:90d8:: with SMTP id k24mr56542584pfk.115.1564712568370; Thu, 01 Aug 2019 19:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712568; cv=none; d=google.com; s=arc-20160816; b=cC2kZFrfnDdH+vosdrmjRy0VMyPZorjDIXBz5IJIsWqwFaO1cCkYps7/h32IysY/ya xB1jS91UdMt4tv7qTlyLzLj8+LrglbAP6AmDZL1AFhaQydGNRQ8UeKrWKFjN5rTFY+S+ zCUau19HuZAVTYgAHiezc8mVHN9tLq7ERN6w+3I2YtIPXtq/jzZvs96RdO3M9z9wU+Ty UYHt0HBhU7FHuVDyEw8Z0zryy1sWS2R+blai0YqW06hJ4ymykBDLWpEHGa3J6A48rQUh shfLMkeIbzoSYR9CQUbZf/7/fTgQKV6dVUw9NRkfxH1VraX6mAftDEmu0RqxkZ5w/jUQ 7SUw== 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=1ar96WJvg+rUGDQFzZ4pf3M5QiEtuEbzxYYlSwg9wfw=; b=XYTuz8g8YZi3U6OvY+Tct0yofVjLq/xnyGS808TxZ6oTfphDm8rVnw1ljdHrV/tYOZ QiDcO83GwY1Z/7VQhpriTyg1bHO5QxW8QLd/nhm+bjx/kNE6ERtwxl24CAq67PbDCVkU IP6WcZfF2/7Heom8B3L8uSwepi0EByB3bodBFZ0vbHmVDuqi58EM44caqj0i5WiDkWCi CT8pbDNPjx/Z44d6gWkrHbfdwR9X9m+s0yMCeQxgkZxIhXgtkZSRGRgYZ3m7Gzc8ubRg asPqp3SkrfbfDDfTMFms8HoumJuG+jVC4NtEge1NHeRf8RQ7Tu9GguzHi2GoQvIcL6Vh kbmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="mSw/yP4y"; 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 v15si35974115pfm.238.2019.08.01.19.22.31; Thu, 01 Aug 2019 19:22:48 -0700 (PDT) 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=bombadil.20170209 header.b="mSw/yP4y"; 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 S1732173AbfHAVoY (ORCPT + 99 others); Thu, 1 Aug 2019 17:44:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40706 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728791AbfHAVoY (ORCPT ); Thu, 1 Aug 2019 17:44:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=1ar96WJvg+rUGDQFzZ4pf3M5QiEtuEbzxYYlSwg9wfw=; b=mSw/yP4yyNvayFNRYt37k8U0h YLMBlZZE4pCYSr8csebvJ9B9G80lFC9+fLMhveGNH29x36ufG1GzxF0ozU4ZdcWLL+6pa8fhTw0CJ wrarjVa7P19K4hNdI7xJ2DjuT81crKkFOiqfKLmVw5GPD4d9IodFMXfiMqJb4bY+WMeUowQc8c04K 1fhc94dc5Cx6QYQdfFy09k7Gh4hIootp5sTyuMOKU3lglbqXfjMXVToT2+aWR36cN0mSxY9z60dY0 utpENwwrpa8D88fZf63usTj/YaFxHbdpRg4Zq4Im8xA+mki59qKoadXgs9NyCFDYDMZrGh0CZDtPV RgIk84eBQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1htIrv-0002tf-BU; Thu, 01 Aug 2019 21:44:15 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 93D3F202953BA; Thu, 1 Aug 2019 23:44:13 +0200 (CEST) Date: Thu, 1 Aug 2019 23:44:13 +0200 From: Peter Zijlstra To: Sean Christopherson Cc: Thomas Gleixner , Oleg Nesterov , LKML , x86@kernel.org, Ingo Molnar , Sebastian Siewior , Anna-Maria Gleixner , Steven Rostedt , Julia Cartwright , Paul McKenney , Frederic Weisbecker , kvm@vger.kernel.org, Radim Krcmar , Paolo Bonzini , John Stultz , Andy Lutomirski , "Paul E. McKenney" Subject: Re: [patch 2/5] x86/kvm: Handle task_work on VMENTER/EXIT Message-ID: <20190801214413.GA2332@hirez.programming.kicks-ass.net> References: <20190801143250.370326052@linutronix.de> <20190801143657.887648487@linutronix.de> <20190801162451.GE31538@redhat.com> <20190801213550.GE6783@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190801213550.GE6783@linux.intel.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 Thu, Aug 01, 2019 at 02:35:50PM -0700, Sean Christopherson wrote: > On Thu, Aug 01, 2019 at 08:34:53PM +0200, Thomas Gleixner wrote: > > On Thu, 1 Aug 2019, Oleg Nesterov wrote: > > > On 08/01, Thomas Gleixner wrote: > > > > > > > > @@ -8172,6 +8174,10 @@ static int vcpu_run(struct kvm_vcpu *vcp > > > > ++vcpu->stat.signal_exits; > > > > break; > > > > } > > > > + > > > > + if (notify_resume_pending()) > > > > + tracehook_handle_notify_resume(); > > > > > > shouldn't you drop kvm->srcu before tracehook_handle_notify_resume() ? > > > > > > I don't understand this code at all, but vcpu_run() does this even before > > > cond_resched(). > > > > Yeah, I noticed that it's dropped around cond_resched(). > > > > My understanding is that for voluntary giving up the CPU via cond_resched() > > it needs to be dropped. > > > > For involuntary preemption (CONFIG_PREEMPT=y) it's not required as the > > whole code section after preempt_enable() is fully preemptible. > > > > Now the 1Mio$ question is whether any of the notify functions invokes > > cond_resched() and whether that really matters. Paolo? > > cond_resched() is called via tracehook_notify_resume()->task_work_run(), > and "kernel code can only call cond_resched() in places where it ... > cannot hold references to any RCU-protected data structures" according to > https://lwn.net/Articles/603252/. This is SRCU, you can reschedule while holding that just fine. It will just delay some kvm operations, like the memslot stuff. I don't think it is terrible to keep it, but people more versed in KVM might know of a good reason to drop it anyway.