Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4427764ioa; Wed, 27 Apr 2022 03:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0uJdLWXuUkogw3inmBxN5aHhA4aVkTlDzYIwEISpJiubTTMjLtnyKbAG70NYsfr0Ci8AJ X-Received: by 2002:a17:902:7001:b0:158:43ba:56cc with SMTP id y1-20020a170902700100b0015843ba56ccmr27157560plk.135.1651056339403; Wed, 27 Apr 2022 03:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056339; cv=none; d=google.com; s=arc-20160816; b=wn7BbAogGJJsQpJIQTHxrogj782CdDmYVu/5rieQXCLBekypV/Dp8ykZb3SwAAXtp6 Y+VwOSblLkQTFW8C0Rci905Ls6TYwpCN4l+3WsWXs8NnrRc4HAGmDOkMWoAa7Jd21nGo 1ehmRtTi+lmMGduLqRhGruQaSUfW6x5ROFR82c+yQL/+fTRsR7mUH9511B3cK6Lgy1SN 7cS6E+ZbExMBBI9DoVLpBTEAWKc1quH4flFIqh+iEGUOvXnBSCbScaPq1VQDp7pcmyvb n53kKMSiPDs+t3VZjtbDtuHLaj4fsDhAFqkzpt7cPr2Sphbp9wX5mXFtcvJmCKmhchC/ aLiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZxvLlCVIbPp4swwXiDKmSMELQTP9l85QUsuRNDye7qY=; b=wmDzWEN5xr2P/F3NWm2ZYjlCL6wGJAW3Z4omv6GDwe1kFGEOlDutIRNU4k66ff3L9m zmyGuSY/p3kVNixTXcpUWRZzFKcC7MoqkHjzDA6ohYluF4YRs0NChJRD8kphLLqI0SwI NhT/DIemmbFeyH4WVpPdtZMEbn80dFLpgLwqwrAeJI1LLT4OEZKlLJbGl0oU3TeAV0/q qy8xzi4jy3PvZy4RAZ2SkPkpDnJqUbiYdh4qOx9C6wC66TH2sGJ0kZE7RxBVmG0Uzhng 4CD9ZMMHHKRTrL0+76dMYpw+rSU28V8MF2FIzRXP0wdHCTb3lRlGoxdS2umHe+mqF2yU 1o9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixgaqSHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s16-20020a170902a51000b00153b2d164cdsi1177039plq.213.2022.04.27.03.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:45:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixgaqSHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA3A0408F9C; Wed, 27 Apr 2022 02:54:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358121AbiD0GcX (ORCPT + 99 others); Wed, 27 Apr 2022 02:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235637AbiD0GcS (ORCPT ); Wed, 27 Apr 2022 02:32:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 982ACDE93E for ; Tue, 26 Apr 2022 23:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651040947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZxvLlCVIbPp4swwXiDKmSMELQTP9l85QUsuRNDye7qY=; b=ixgaqSHzslEcPRHzYrQOtyVOZ5TTCh5rs/AHR/dIC9BfJkr2ZxZPhOhNkZrXlIF++d1tlD oea9XAX/GuY8hY7Z6oXKKbPe5tvXOVCHINxUMf5h+rgKfalYa+YEZZ9wE+jwVheoidee7R VoyVK2qOwOoObOcFZqhwdSoYZudZy2U= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-LhIXkYrHMi63fuq4Rr1uwA-1; Wed, 27 Apr 2022 02:29:06 -0400 X-MC-Unique: LhIXkYrHMi63fuq4Rr1uwA-1 Received: by mail-wr1-f71.google.com with SMTP id e21-20020adfa455000000b0020ae075cf35so344194wra.11 for ; Tue, 26 Apr 2022 23:29:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=ZxvLlCVIbPp4swwXiDKmSMELQTP9l85QUsuRNDye7qY=; b=Pd2k3hvCmL+AWzK8l12NKA2j0r8ezg9gj92qOaXctft8vD7F72FmaWmLgKLW8PLtHe kV5WmDAW9USj3NPV+AaM5KHSK6HAMOncqQYTMN/rxpBzKOYbXCLaMpnXqUZ2OiChyaYY S29ZJMLqXS2os+20bp/ntugMQMhIGZNv313CPAxwWGVfznd2kyz4jGVPuNjMJzpn5CR5 mTuapToM0vtBs9sl9ol2iDScOg2qDOSx+g9nNxz80SPQrNuGCYUxrU0DSZRo8mX5kpM6 klkkr/wnI8m0D2pMZEHIZBYVOt+XepMOzAlo6BF803R67cyC9TeaZDaDu16B1/gsjqdz c3zA== X-Gm-Message-State: AOAM531PxLjSbaB/99EJlPNuvYMd9Yx8q5hnOSfcaqX+Zqx5IRaLkiUz v4tG1Xzy1kesmQBayN4AbMMwwHiHuBMy8udUVMt6aI4CGOVR64pYKIfIjVFWYfMQhBBc7GjgGwy EBsutPgJurUi6a5OXWYpmtDEv X-Received: by 2002:a05:6000:1acf:b0:20a:9c20:c769 with SMTP id i15-20020a0560001acf00b0020a9c20c769mr22279950wry.467.1651040945171; Tue, 26 Apr 2022 23:29:05 -0700 (PDT) X-Received: by 2002:a05:6000:1acf:b0:20a:9c20:c769 with SMTP id i15-20020a0560001acf00b0020a9c20c769mr22279929wry.467.1651040944951; Tue, 26 Apr 2022 23:29:04 -0700 (PDT) Received: from redhat.com ([2.53.18.16]) by smtp.gmail.com with ESMTPSA id m41-20020a05600c3b2900b00393e6f6c130sm850563wms.42.2022.04.26.23.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 23:29:03 -0700 (PDT) Date: Wed, 27 Apr 2022 02:28:59 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Halil Pasic , Cornelia Huck , linux-kernel , virtualization , Stefano Garzarella , eperezma , Cindy Lu , Thomas Gleixner , Peter Zijlstra , "Paul E. McKenney" , Marc Zyngier Subject: Re: [PATCH V3 6/9] virtio-ccw: implement synchronize_cbs() Message-ID: <20220427022634-mutt-send-email-mst@kernel.org> References: <20220425095742-mutt-send-email-mst@kernel.org> <20220426042911.544477f9.pasic@linux.ibm.com> <20220425233434-mutt-send-email-mst@kernel.org> <20220425233604-mutt-send-email-mst@kernel.org> <20220425235134-mutt-send-email-mst@kernel.org> <20220425235415-mutt-send-email-mst@kernel.org> <20220426022420-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2022 at 11:53:25AM +0800, Jason Wang wrote: > On Tue, Apr 26, 2022 at 2:30 PM Michael S. Tsirkin wrote: > > > > On Tue, Apr 26, 2022 at 12:07:39PM +0800, Jason Wang wrote: > > > On Tue, Apr 26, 2022 at 11:55 AM Michael S. Tsirkin wrote: > > > > > > > > On Mon, Apr 25, 2022 at 11:53:24PM -0400, Michael S. Tsirkin wrote: > > > > > On Tue, Apr 26, 2022 at 11:42:45AM +0800, Jason Wang wrote: > > > > > > > > > > > > 在 2022/4/26 11:38, Michael S. Tsirkin 写道: > > > > > > > On Mon, Apr 25, 2022 at 11:35:41PM -0400, Michael S. Tsirkin wrote: > > > > > > > > On Tue, Apr 26, 2022 at 04:29:11AM +0200, Halil Pasic wrote: > > > > > > > > > On Mon, 25 Apr 2022 09:59:55 -0400 > > > > > > > > > "Michael S. Tsirkin" wrote: > > > > > > > > > > > > > > > > > > > On Mon, Apr 25, 2022 at 10:54:24AM +0200, Cornelia Huck wrote: > > > > > > > > > > > On Mon, Apr 25 2022, "Michael S. Tsirkin" wrote: > > > > > > > > > > > > On Mon, Apr 25, 2022 at 10:44:15AM +0800, Jason Wang wrote: > > > > > > > > > > > > > This patch tries to implement the synchronize_cbs() for ccw. For the > > > > > > > > > > > > > vring_interrupt() that is called via virtio_airq_handler(), the > > > > > > > > > > > > > synchronization is simply done via the airq_info's lock. For the > > > > > > > > > > > > > vring_interrupt() that is called via virtio_ccw_int_handler(), a per > > > > > > > > > > > > > device spinlock for irq is introduced ans used in the synchronization > > > > > > > > > > > > > method. > > > > > > > > > > > > > > > > > > > > > > > > > > Cc: Thomas Gleixner > > > > > > > > > > > > > Cc: Peter Zijlstra > > > > > > > > > > > > > Cc: "Paul E. McKenney" > > > > > > > > > > > > > Cc: Marc Zyngier > > > > > > > > > > > > > Cc: Halil Pasic > > > > > > > > > > > > > Cc: Cornelia Huck > > > > > > > > > > > > > Signed-off-by: Jason Wang > > > > > > > > > > > > > > > > > > > > > > > > This is the only one that is giving me pause. Halil, Cornelia, > > > > > > > > > > > > should we be concerned about the performance impact here? > > > > > > > > > > > > Any chance it can be tested? > > > > > > > > > > > We can have a bunch of devices using the same airq structure, and the > > > > > > > > > > > sync cb creates a choke point, same as registering/unregistering. > > > > > > > > > > BTW can callbacks for multiple VQs run on multiple CPUs at the moment? > > > > > > > > > I'm not sure I understand the question. > > > > > > > > > > > > > > > > > > I do think we can have multiple CPUs that are executing some portion of > > > > > > > > > virtio_ccw_int_handler(). So I guess the answer is yes. Connie what do you think? > > > > > > > > > > > > > > > > > > On the other hand we could also end up serializing synchronize_cbs() > > > > > > > > > calls for different devices if they happen to use the same airq_info. But > > > > > > > > > this probably was not your question > > > > > > > > > > > > > > > > I am less concerned about synchronize_cbs being slow and more about > > > > > > > > the slowdown in interrupt processing itself. > > > > > > > > > > > > > > > > > > this patch serializes them on a spinlock. > > > > > > > > > > > > > > > > > > > Those could then pile up on the newly introduced spinlock. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Halil > > > > > > > > Hmm yea ... not good. > > > > > > > Is there any other way to synchronize with all callbacks? > > > > > > > > > > > > > > > > > > Maybe using rwlock as airq handler? > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > rwlock is still a shared cacheline bouncing between CPUs and > > > > > a bunch of ordering instructions. > > > > > > Yes, but it should be faster than spinlocks anyhow. > > > > > > > > Maybe something per-cpu + some IPIs to run things on all CPUs instead? > > > > > > Is this something like a customized version of synchronzie_rcu_expedited()? > > > > With interrupts running in an RCU read size critical section? > > For vring_interrupt(), yes. > > > > Quite possibly that is also an option. > > This will need a bunch of documentation since this is not > > a standard use of RCU, > > According to Documentation/RCU/requirements.rst, it looks like a legal case: > > " > The Linux kernel has interrupts, and RCU read-side critical sections are > legal within interrupt handlers and within interrupt-disabled regions of > code, as are invocations of call_rcu(). > " > > And as discussed, synchronize_rcu_expedited() is not friendly to real > time workload. I am not sure hotplug removal is relevant for realtime anyway though. > I think we can simply > > 1) protect vring_interrupt() with rcu_read_lock() > 2) use synchronize_rcu() in synchronize_cbs for ccw > > And if we care about the long delay we can use per device srcu to reduce that? > > Thanks Maybe ... > > and probably get a confirmation > > from RCU maintainers that whatever assumptions we make > > are guaranteed to hold down the road. > > > > > > > > > > ... and I think classic and device interrupts are different enough > > > > here ... > > > > > > Yes. > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > MST > > > > > >