Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6079156imu; Wed, 30 Jan 2019 08:27:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN7pr4z7zUjciuGz8xRHm2ufMljUK9KloPkDNi6qJYzieRh7O5QgHFOmtdL/8FRFO/4WDLjz X-Received: by 2002:a17:902:e012:: with SMTP id ca18mr30934945plb.218.1548865625057; Wed, 30 Jan 2019 08:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548865625; cv=none; d=google.com; s=arc-20160816; b=bfhxoYh2RcG37rB17vrsFiwjIamJ0bUaxiOYMcthuiPnTZqHzHMiJhqhw/yu+rTWV3 1moGnlKH8pmrZCGiqSYMVwNTQ6yvMQg4sGBauAexawI9bnn/oxJdUj+u57sjhxyd5J/q O0EOkPeLibBTphXCrC2sUdvH3scnfIF9/Ok2mrZ5JHBhusIFQpDSZi3SQer+OffjtBrv USA+Tn9vcQAG/Na6fyG23kACdp0Vz59/TPY+sp4Qkfyd9xH3Y/+/t09Q7804ANOKzrA/ 34EKz/dW+Qbw3nS/3YsscMH4qvJH7t/9jrhmt6U9f4+Kso97SngWWpiBfiuxQaR5GIdf NfKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:reply-to; bh=gCZGKrO0oSNz+Ka/Sbdzht46x7fX5EWgArLShiWYK5Y=; b=UHXHn5PkH6zAaccZH1bYW6Xi03XFWFiseKFW99aiZUSGLPWeS623qw1bV3a/TzGbEZ G4+m7FCvUd+oU7tjmZecf1BEJc51AmTXXYxssxe2qUVGhvi/dxn2tCruWLqpXi/T8aBU SQO9HF/Twqmou9cI8cCv4rkBHaCmnfwuo2tOdsZIBgTQ6onqbieJKow91sJEC+cXIAJk ZPG54v2oqHj2qMdy2KSYD7YVODCUqEoiFnnJbscvBSvm2hZ4cCuOZzzE5zSr7uwIvuRx hoVe8ss5FsONvhs7PNeu75IzKiPKDIvyFPh1+jyKPt5QtNMK+uxIuvBquk+UqAUa6KzJ PAaw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si2073836pln.289.2019.01.30.08.26.49; Wed, 30 Jan 2019 08:27:05 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731363AbfA3Q0E (ORCPT + 99 others); Wed, 30 Jan 2019 11:26:04 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53162 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729299AbfA3Q0D (ORCPT ); Wed, 30 Jan 2019 11:26:03 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0UGPmhA075181 for ; Wed, 30 Jan 2019 11:26:02 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2qbddcy5cj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 30 Jan 2019 11:25:55 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Jan 2019 16:24:55 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 30 Jan 2019 16:24:51 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0UGOoq656426514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 Jan 2019 16:24:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FF6BAE057; Wed, 30 Jan 2019 16:24:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83550AE053; Wed, 30 Jan 2019 16:24:49 +0000 (GMT) Received: from [9.152.224.140] (unknown [9.152.224.140]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Jan 2019 16:24:49 +0000 (GMT) Reply-To: pmorel@linux.ibm.com Subject: Re: [PATCH v6 12/13] KVM: s390: add gib_alert_irq_handler() To: mimu@linux.ibm.com, Halil Pasic Cc: KVM Mailing List , Linux-S390 Mailing List , linux-kernel@vger.kernel.org, Martin Schwidefsky , Heiko Carstens , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck References: <20190124125939.130763-1-mimu@linux.ibm.com> <20190124125939.130763-13-mimu@linux.ibm.com> <20190129142642.3a94a5f1@oc2783563651> <3819a46e-b2cf-96e3-b3b8-6cdf35eeb616@linux.ibm.com> From: Pierre Morel Date: Wed, 30 Jan 2019 17:24:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <3819a46e-b2cf-96e3-b3b8-6cdf35eeb616@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19013016-4275-0000-0000-00000307E97F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19013016-4276-0000-0000-00003815F012 Message-Id: <7f33ff97-9503-9b32-b244-1e8104d0408e@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-30_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=845 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901300128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/01/2019 16:29, Michael Mueller wrote: > > > On 29.01.19 14:26, Halil Pasic wrote: >> On Thu, 24 Jan 2019 13:59:38 +0100 >> Michael Mueller wrote: >> >>> The patch implements a handler for GIB alert interruptions >>> on the host. Its task is to alert guests that interrupts are >>> pending for them. >>> >>> A GIB alert interrupt statistic counter is added as well: >>> >>> $ cat /proc/interrupts >>>            CPU0       CPU1 >>>    ... >>>    GAL:      23         37   [I/O] GIB Alert >>>    ... >>> >>> Signed-off-by: Michael Mueller >> [..] >>> +/** >>> + * gisa_get_ipm_or_restore_iam - return IPM or restore GISA IAM >>> + * >>> + * @gi: gisa interrupt struct to work on >>> + * >>> + * Atomically restores the interruption alert mask if none of the >>> + * relevant ISCs are pending and return the IPM. >> >> The word 'relevant' probably reflects some previous state. It does not >> bother me too much. > > "relevant" refers to the ISCs handled by the GAL mechanism, i.e those > registered in the kvm->arch.gisa_int.alert.mask. > >> >> [..] >> >>> +static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 >>> deliverable_mask) >>> +{ >>> +    int vcpu_id, online_vcpus = atomic_read(&kvm->online_vcpus); >>> +    struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; >>> +    struct kvm_vcpu *vcpu; >>> + >>> +    for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) { >>> +        vcpu = kvm_get_vcpu(kvm, vcpu_id); >>> +        if (psw_ioint_disabled(vcpu)) >>> +            continue; >>> +        deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24); >>> +        if (deliverable_mask) { >>> +            /* lately kicked but not yet running */ >> >> How about /* was kicked but didn't run yet */? > > what is the difference here... > >> >>> +            if (test_and_set_bit(vcpu_id, gi->kicked_mask)) >>> +                return; >>> +            kvm_s390_vcpu_wakeup(vcpu); >>> +            return; >>> +        } >>> +    } >>> +} >>> + >> >> [..] >> >>> +static void process_gib_alert_list(void) >>> +{ >>> +    struct kvm_s390_gisa_interrupt *gi; >>> +    struct kvm_s390_gisa *gisa; >>> +    struct kvm *kvm; >>> +    u32 final, origin = 0UL; >>> + >>> +    do { >>> +        /* >>> +         * If the NONE_GISA_ADDR is still stored in the alert list >>> +         * origin, we will leave the outer loop. No further GISA has >>> +         * been added to the alert list by millicode while processing >>> +         * the current alert list. >>> +         */ >>> +        final = (origin & NONE_GISA_ADDR); >>> +        /* >>> +         * Cut off the alert list and store the NONE_GISA_ADDR in the >>> +         * alert list origin to avoid further GAL interruptions. >>> +         * A new alert list can be build up by millicode in parallel >>> +         * for guests not in the yet cut-off alert list. When in the >>> +         * final loop, store the NULL_GISA_ADDR instead. This will re- >>> +         * enable GAL interruptions on the host again. >>> +         */ >>> +        origin = xchg(&gib->alert_list_origin, >>> +                  (!final) ? NONE_GISA_ADDR : NULL_GISA_ADDR); >>> +        /* >>> +         * Loop through the just cut-off alert list and start the >>> +         * gisa timers to kick idle vcpus to consume the pending >>> +         * interruptions asap. >>> +         */ >>> +        while (origin & GISA_ADDR_MASK) { >>> +            gisa = (struct kvm_s390_gisa *)(u64)origin; >>> +            origin = gisa->next_alert; >>> +            gisa->next_alert = (u32)(u64)gisa; >>> +            kvm = container_of(gisa, struct sie_page2, gisa)->kvm; >>> +            gi = &kvm->arch.gisa_int; >>> +            if (hrtimer_active(&gi->timer)) >>> +                hrtimer_cancel(&gi->timer); >>> +            hrtimer_start(&gi->timer, 0, HRTIMER_MODE_REL); >>> +        } >>> +    } while (!final); >>> + >>> +} >>> + >>>   void kvm_s390_gisa_clear(struct kvm *kvm) >>>   { >>>       struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; >>>       if (!gi->origin) >>>           return; >>> -    memset(gi->origin, 0, sizeof(struct kvm_s390_gisa)); >>> -    gi->origin->next_alert = (u32)(u64)gi->origin; >>> +    gisa_clear_ipm(gi->origin); >> >> This could be a separate patch. I would like little more explanation >> to this. > > I can break at out as I had before... ;) > >> >>>       VM_EVENT(kvm, 3, "gisa 0x%pK cleared", gi->origin); >>>   } >>> @@ -2940,13 +3078,25 @@ void kvm_s390_gisa_init(struct kvm *kvm) >>>       gi->origin = &kvm->arch.sie_page2->gisa; >>>       gi->alert.mask = 0; >>>       spin_lock_init(&gi->alert.ref_lock); >>> -    kvm_s390_gisa_clear(kvm); >>> +    gi->expires = 50 * 1000; /* 50 usec */ >> >> I blindly trust your choice here ;) > > You know I will increase it to 1 ms together with the change that I > proposed. (gisa_get_ipm_or_restore_iam() in kvm_s390_handle_wait()). With this. Reviewed-by: Pierre Morel -- Pierre Morel Linux/KVM/QEMU in Böblingen - Germany