Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2511539pxb; Tue, 21 Sep 2021 01:12:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3jCZ+IIhMTwZs/JcyezsVkXeEKp7EOkQqLPsTXLMqARjby9Ne5FqsFZ+Hmuv95tU3GJia X-Received: by 2002:a05:6e02:1a67:: with SMTP id w7mr19664319ilv.215.1632211967955; Tue, 21 Sep 2021 01:12:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632211967; cv=pass; d=google.com; s=arc-20160816; b=YM/PVSsNjGhL3NOqK1rJeB4KwH8RVips3e0HqhlrU8j2Y36SFOLZQNr7CB6J7fYJ86 ovmauHTzR3pQDGmr/xXFq+Qw7oXIkWkjaJ7TM78AFHxlCx6xAcAfbIsCOuRQFIfjTtes Q09eiiJRGugb2VXJf8vubATH2JDwWtzASohhlQaxO+uBM+RJOdqrkC6l1XLrtH3haPk8 r+gOc6EaOYIesygb0Jq83/RjLHOKc0ZtRghkVGUKi4fbrwB65GF/wbn1wHeDUMKp0xnq pOPdhBLqS+qBKukxNEtsY9x2DpwjCZzBB+Im6TGYO8qr8SY3jeDLypXp6qzFVAx9DR/K vSPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=q4DEfjy8i3majxxWRX69gfYnq7AfsHgE+0qIFCaUyk8=; b=x6vobhej/k9udtncJY9VnlM1Z7GB0JntSknD/STGrMhvkhB1iFMW3SqvJa4p2+vGh0 OETJbL/tHP4OCVxcJ5CdjOx4A0+EuRaudm5zTK5bBBJsCNHoSsm9oN/2f1i1J6DrfR9J T+CZJFj9KnN0OSJAAKABZgTZHJT5X9m14DjDyQG0nT/qZWb4F0FVT+FM2m8Z7BdswGrN OdHipVSN8cR48WDtgigUbNgSBv+c9asEmsTo4U+BG1MHXKHV5XRAt7A6h25c4+0FzAwu gxjeWtx6+P/1qKidtYGETASpezjcqupZ3jicYuznkQLXA5kRK7lhxDKWLc+cssA1TwWz 3nzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=E+aqtBhV; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si17428883iol.44.2021.09.21.01.12.36; Tue, 21 Sep 2021 01:12:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=E+aqtBhV; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbhIUIMy (ORCPT + 99 others); Tue, 21 Sep 2021 04:12:54 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.109.102]:37189 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhIUIMx (ORCPT ); Tue, 21 Sep 2021 04:12:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632211884; 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=q4DEfjy8i3majxxWRX69gfYnq7AfsHgE+0qIFCaUyk8=; b=E+aqtBhVIddgLXym5o/krGWW7RMR/bMXherR1Xa6Quao49L56XTquqYmbivgg6ezE0skjz upIcYY7BwZQQWQbW4SHaJn757M+7gXbpWVwqtU23LOwKTKTkfGbTnQ4ic+/6IYTFqLItVf GOBtpjy5bFhkIai+7SKj+wWmntpnKZk= Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2105.outbound.protection.outlook.com [104.47.18.105]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-1-IIj35TnaO_GnjHAXRa2YKg-2; Tue, 21 Sep 2021 10:11:23 +0200 X-MC-Unique: IIj35TnaO_GnjHAXRa2YKg-2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3eWvomNzQPz7UInTvPpt3TV8/uUKAvkBiQ7CINIEAiaQ9zHM7pDU7NViFRwFrxR/8P1bzUngGTM7HIQnjH3IYbkXhx8gBhBGkCgP2N9//cC5hrYYKGBztho66FP3Nw4N7thMUReCK379HCxgWxiJJn4HhMOd9cE50Qh9OckS7PsG5RGYEL5UMDrcBc848K7fNcjUTruKoMp760wEQmK8JeeRErBUlyaA82Xy/gNKskfYVkkxbMQqcRdEHmC6ONzKPztIXkU5nsHZ+tHEEKjgzrH7xWbRvMNEn6Z1JB+FV8yR/wXgYOh7UPc9EVaPafiV6nqwgaolwwiGXG0FIclFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=q4DEfjy8i3majxxWRX69gfYnq7AfsHgE+0qIFCaUyk8=; b=C1BJ6PquMPSCR9wReG3akAIduEsN4m2GWuzOXyXy9xdMpRxytGOisxsD+eytzYKUs3Bk6R45aU4m3mmjxkTVaNX6WTKW4mq1H7lztdbK/9HzNTV9HnNGiGaVNe7nKBX1JI0mwhPTv8nyz5BK3JYnemb7UenNGXJoxny1FadhNNe/7n2meULrwoNangnw8ebRyBRSI/bB83JYepsuL4BqPFQaEidIm43NOugdks1yFeQOoMU19bqxnTVbcIupSU084/V3IuTQayYQ9RJapVMtvDiZIi3ZowIz8qomPf45BrnhviCA3udrrBdcn6s4Zfe166tUSlH63bLPsm2ByXpFDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB7152.eurprd04.prod.outlook.com (2603:10a6:800:12b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 21 Sep 2021 08:11:18 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 08:11:18 +0000 Subject: Re: [PATCH] x86/xen: remove unneeded preempt_disable() from xen_irq_enable() To: Juergen Gross Cc: Boris Ostrovsky , Stefano Stabellini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20210921070226.32021-1-jgross@suse.com> <99e6cf1d-ce6a-83e5-2e43-12f6c1a89f3f@suse.com> <599f4e20-a25d-6cd0-ced5-f2deaf997535@suse.com> From: Jan Beulich Message-ID: <6305dfb1-15bc-ce4b-cbf7-d44ef5c0456d@suse.com> Date: Tue, 21 Sep 2021 10:11:16 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <599f4e20-a25d-6cd0-ced5-f2deaf997535@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PR0P264CA0227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1e::23) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.156.60.236] (37.24.206.209) by PR0P264CA0227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 08:11:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d6095ff-2796-4f89-e21e-08d97cd76398 X-MS-TrafficTypeDiagnostic: VI1PR04MB7152: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ojROy3FgOMDxO6SI1kQi8nnpzENpcLinDsQpSlt9VGleDHJAkq4rZPkYpDFqGJQuE2+crXxoY2uyaKLr0N1D1D51uBQnQ0p9FIK4UaUS+gGDwyZD3zILEdzgWa7NouMHzqL9tBnHKkCG4/zAANj9mtvXBtcGy6NPti1KzXFIpoe9brP73gPamfEJd1PvTBdzu3TAcIcq1KjCtPfm1xLPAKpf4suwF9P6pSDYmyO7od6Uh1fn5917QkxFpDQvw+ITvHwc/UsMR0XbKKZceJay81vHYKxbDnuRG7IB7O3R2OCx2FKkHWEvuHsWeUeA+jNrAWK/yeFOr5u/bwgZsiMmQMpdzFqa75zBKolz/bPSQJ7BbBmX3uiWLWt/dnYy4LOHzoIKPtEiRIH7u4fKFrbWKxRNgDRGuo7GrWmz8XH4vAeWbdH0jbb8jPiSXDrPwGHcmhKRfdhy6rXoLhTOiZho0IH1uPV4/kYStnQATlitdoBAtC610Wluh3grPxe1Rv1C/CKL7djzWaxiEg7bHqB1PEpul5vnKCzn+hsZNLNwoKwcY5uF+wrfAMP089DhPU1nTkMhkwBlevSebs/1XTbtVEySMi87T9MuaNy7HnuR1ge5SjwQaoHzI99k5+uA1mzlKBbNYzrhnNsJEU06UcAgN0SZMuFyp2jznlcTh1xxLzc7QyZjpNSh8CNjiM+5YP1IkWPqVHC7u2+1QOsxHoa8MNPddijOvcilo+bDeS7CuYs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6636002)(16576012)(31686004)(37006003)(54906003)(316002)(38100700002)(6486002)(2906002)(83380400001)(26005)(36756003)(8936002)(186003)(6862004)(53546011)(4326008)(2616005)(31696002)(956004)(86362001)(66946007)(66556008)(66476007)(508600001)(8676002)(5660300002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K1JDYzlvbEJDMHZNNVFzWTZLYkpFNk5VbDNIWmpmRk5BUVhCYld1SGNiSDd4?= =?utf-8?B?bFNlRE13K2VLL3JGNjd5bjYvYjJBbm9CS2gzSHp1cXl4WmIzNmxDV1doTTEr?= =?utf-8?B?bGVCTjFSVWJCbk1xN3FhR1poT0ttZEk4Ylh2TFhvS0xvZzJ0YUNaSDBSemc0?= =?utf-8?B?ZDlqR1VYWjFPMTRYT0M5ZDRxZ3N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hrOEg4c1JzRXZnVGMwb3pxVHBYeFdxMkVIQzdUMWMwbVdT?= =?utf-8?B?MnhUR3NYWERZYy9XelR6WjdlczAwcDZzZ2p2Z1paVFNuYTFhQkxmQTRmNzdM?= =?utf-8?B?bmJlVkNUMlpwbFpqRVhuTk93N29OYWlqR3A0cEVISlBwU2ViK2grdFhZbE5W?= =?utf-8?B?UVlRMWdFWlRHLzh6TXJzeWZ2aVg1Q2txZXB1U3ZWaVBMOEtLQm9GT1BvSkRY?= =?utf-8?B?VENqYjdZd2E2S3lvclBVbGp5WXdmQ0Fpc2g3MktRNlJERm53ZkdRb2hQYVhP?= =?utf-8?B?aFpXM1lwbzczdWd0UWJwZHVGN1JHUndNR1Vud0pHY2FvYWd3bEVjbjFlU0tR?= =?utf-8?B?ajdXTmtUNllTSnA2UHlVTkpPN0kvOWtleEdvVkJtYzZabUpZZlE1dnlSQ0tT?= =?utf-8?B?Vy80WkpGN1dTSXIxU29hSG9yVHlFUDhBNXFKS0hxYmo2amtKQjIxTmVjLzBB?= =?utf-8?B?MEp6NDV6dGMvSDZMdWJMSW1OQUVMVDV0RmdUQ1NGSWQ5T0Z6U1lEVFAxdFpz?= =?utf-8?B?RFFud1RhMWJYc1N2SDdrM3dPL1pZWmhHekZLc1BWakl2U000OUFRU0h0U2dZ?= =?utf-8?B?ekVnakozMGo1QUltdGdTTnU2cXVxN1FDWmlvOFRDMTNYTGQ2eE01aHluSUE3?= =?utf-8?Q?H8uyPgvi4Hv7x6xKV64Tt/I0zbjA8f1Cu6aIyfU?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d6095ff-2796-4f89-e21e-08d97cd76398 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 08:11:18.1461 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HwE+hrgPnN352yJ+5qQVGcWkSy3VpA+m4sZxPvB5p9MSnyqViZ9i1ZJtPsiY9zICex1ZxuJR4LIfyoXKxrfbkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7152 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.09.2021 09:58, Juergen Gross wrote: > On 21.09.21 09:53, Jan Beulich wrote: >> On 21.09.2021 09:02, Juergen Gross wrote: >>> --- a/arch/x86/xen/irq.c >>> +++ b/arch/x86/xen/irq.c >>> @@ -57,24 +57,20 @@ asmlinkage __visible void xen_irq_enable(void) >>> { >>> struct vcpu_info *vcpu; >>> >>> - /* >>> - * We may be preempted as soon as vcpu->evtchn_upcall_mask is >>> - * cleared, so disable preemption to ensure we check for >>> - * events on the VCPU we are still running on. >>> - */ >>> - preempt_disable(); >>> - >>> vcpu = this_cpu_read(xen_vcpu); >>> vcpu->evtchn_upcall_mask = 0; >>> >>> - /* Doesn't matter if we get preempted here, because any >>> - pending event will get dealt with anyway. */ >>> + /* >>> + * Now preemption could happen, but this is only possible if an event >>> + * was handled, so missing an event due to preemption is not >>> + * possible at all. >>> + * The worst possible case is to be preempted and then check events >>> + * pending on the old vcpu, but this is not problematic. >>> + */ >> >> I agree this isn't problematic from a functional perspective, but ... >> >>> barrier(); /* unmask then check (avoid races) */ >>> if (unlikely(vcpu->evtchn_upcall_pending)) >>> xen_force_evtchn_callback(); >> >> ... is a stray call here cheaper than ... >> >>> - >>> - preempt_enable(); >> >> ... the preempt_{dis,en}able() pair? > > The question is if a stray call in case of preemption (very unlikely) > is cheaper than the preempt_{dis|en}able() pair on each IRQ enabling. > > I'm quite sure removing the preempt_*() calls will be a net benefit. Well, yes, I agree. It would have been nice if the description pointed out the fact that preemption kicking in precisely here is very unlikely. But perhaps that's considered rather obvious ... The issue I'm having is with the prior comments: They indicated that preemption happening before the "pending" check would be okay, _despite_ the preempt_{dis,en}able() pair. One could view this as an indication that this pair was put there for another reason (e.g. to avoid the stray calls). But it may of course also be that the comment simply was stale. Reviewed-by: Jan Beulich Jan