[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/8] xen/evtchn: modify evtchn_bind_interdomain to allocate specified port
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Rahul Singh <Rahul.Singh@xxxxxxx>
- Date: Wed, 6 Jul 2022 11:59:39 +0000
- Accept-language: en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xTcn2qsjfcs/sS6vCPWitDMWsvpXLXSi6QJa5DTFGPo=; b=Fo3gDFGPIMF7h30hYPeO3fMuoA6p1DIBTXU6Bflcz4mwuaNk/BiYNwb9xywrOo7pg1fEADar4Yq0hULouV2WDQmoyYjV9hKofRRmVF5UlZYIRDpl5I+8j9p7Z+vOwPDJAaO2mQPPcv2hxchi1QHHUzWXGvhWUs0M0cwyudxSHWSA8nX7bqCxQ0N9dufaxitcykzt0njKl6IZ/IH7js48JHFaCeQ8WMbujtojDwPkGa1FaQ04zmmi7/8mUNwEwh86mjiRaSMwDLEPto0YUSwixXlQeBRzLvIJDQpnIupHOU/RelCP/qy9d3ln4NqiKT7pUbUMacywCudXrWgw+W4hAg==
- 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xTcn2qsjfcs/sS6vCPWitDMWsvpXLXSi6QJa5DTFGPo=; b=fGpgegX81ObHneF0RKf6v7uC77iBgUfNFAHc1qgqJAlC1QVmlIxn/zga4tJe0wutK9HXtYbBkS6B18CcXXfkzRpJ/dvJbp5phpKJ4sUgsIchQ24qaaQOR56u/r1hsKN2L40pTUnAP1mselZDqTDw6KDTzkNuRo0TabqGAI8/B9+ZNZO6wtWmGfLLMBUJBOBwbcdN3GHeLTuq9VjutnbZFCE9ReotlpVc1KjMTqFSENqX1BCOkoEqSysxCpUgKqA9i/070LAQ0ja0LE/7l6jfFpTF3JBmiQAOnPdZZYddVCidcEU+s+UJ+a96wf7qa+JT4B4r207NHquXkNktIJbFlA==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=b4mlFdbmkKgdL+Mp5CxatbqjQDaGbyDId7XyzreOvyxzP38C41FZooqO1rpN5SSBdh8RW3uViA2pRGe+Cv4CK4m9gu+aM4TyJFU9nuv1TbHneaqlIdgSwwMr7DNN4GHIn6MmtphsbL01mMbs/j3KzGeUX9czq59vUBUOQe2iO8yqxSfgPobM5vAliWoXjm3omvD7gzA7Z73ikKiZEvG630SI+sy18Tkn2eu1CwHzZNoglHwtNrZ4dMFUocJVDR1DKj/Wx5XuacIhO/6WbuhmtmCTFabrx3lYomNFaGju+L+BWHmgSTYmpngi6Fbxuaewcuf4zlEC8kYgDK7oeSNuVg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMWT6iiNU8gEDxrIInVTfjw+++1ZGaHiJgGxNV5h8ikmyLTVo72HZErQvkUGRSx9RaWPixgSvcH/7UL9z5b32OR2O73vmbMpt/pWlrjUEHrjUFazmiz/y3LNfW39fEMuot6XwU5kRkXFPHF96iRhybpbNYHuIq27PyyPBtSeLTsPqHyV91S2CZgDtW0fmS9SDHO+ltXl4NNAR5YbpfYbKE9+H2vjWHdjcCgyRa64ZMeBHbAr55h3ClKi+BcqYr6z0RbP6fNW8UnqXhLGZ4IRRqsh4ftlmVbbmE2OABlKBObEffDjuYG9ck5Kg6NXszQ19ob28wvEXl7F4qtEXzAPew==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Wed, 06 Jul 2022 11:59:57 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHYhkXgFvoQlpdPN0O1CKuVc36nOK1v9mEAgAADLoCAAAWTAIABVA4A
- Thread-topic: [PATCH 3/8] xen/evtchn: modify evtchn_bind_interdomain to allocate specified port
Hi Jan
> On 5 Jul 2022, at 4:42 pm, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>
> On 05.07.2022 17:22, Julien Grall wrote:
>> Hi Jan,
>>
>> On 05/07/2022 16:11, Jan Beulich wrote:
>>> On 22.06.2022 16:38, Rahul Singh wrote:
>>>> @@ -387,8 +392,19 @@ int evtchn_bind_interdomain(evtchn_bind_interdomain_t
>>>> *bind)
>>>> spin_lock(&ld->event_lock);
>>>> }
>>>>
>>>> - if ( (lport = get_free_port(ld)) < 0 )
>>>> - ERROR_EXIT(lport);
>>>> + if ( lport != 0 )
>>>> + {
>>>> + if ( (rc = evtchn_allocate_port(ld, lport)) != 0 )
>>>> + ERROR_EXIT_DOM(rc, ld);
>>>> + }
>>>> + else
>>>> + {
>>>> + int alloc_port = get_free_port(ld);
>>>> +
>>>> + if ( alloc_port < 0 )
>>>> + ERROR_EXIT_DOM(alloc_port, ld);
>>>> + lport = alloc_port;
>>>> + }
>>>
>>> This is then the 3rd instance of this pattern. I think the logic
>>> wants moving into get_free_port() (perhaps with a name change).
>>
>> I think the code below would be suitable. I can send it or Rahul can
>> re-use the commit [1]:
>
> Ah yes; probably makes sense (right now) only in the context of his
> series.
Ack.
>
>> --- a/xen/common/event_channel.c
>> +++ b/xen/common/event_channel.c
>> @@ -292,6 +292,18 @@ void evtchn_free(struct domain *d, struct evtchn *chn)
>> xsm_evtchn_close_post(chn);
>> }
>>
>> +static int evtchn_get_port(struct domain *d, uint32_t port)
>
> Preferably evtchn_port_t.
Ack.
>
>> +{
>> + int rc;
>> +
>> + if ( port != 0 )
>> + rc = evtchn_allocate_port(d, port);
>> + else
>> + rc = get_free_port(d);
>> +
>> + return rc != 0 ? rc : port;
>
> We commonly use "rc ?: port" in such cases. At which point I'd be
> inclined to make it just
>
> static int evtchn_get_port(struct domain *d, evtchn_port_t port)
> {
> return (port ? evtchn_allocate_port(d, port)
> : get_free_port(d)) ?: port;
> }
>
> But I can see you or others having reservations against such ...
If everyone agree with above code I will modify the Julien patch to include
this code in next version.
Regards,
Rahul
|