Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp486804pxb; Wed, 29 Sep 2021 03:44:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlP7g+HpegEzIvAORWI35aheJz2AepOpvqRm59yykXhL0mxCG6zjTA05OlMW3UjFSFb1ws X-Received: by 2002:a63:5608:: with SMTP id k8mr8956562pgb.287.1632912299652; Wed, 29 Sep 2021 03:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632912299; cv=none; d=google.com; s=arc-20160816; b=R+82PgWb0xNNJ6N86FDCNgPkKOHpjsGPbEQ983ZvTqzOXpTq79/UGezRFd39PP6ij6 sMNX7VTuEEQHDSkK4GSQ4z2GvRRCRZSBjbomXRwoMIWv/FjXrM3zM2ogAfNI3mHmAVov IVT8K7ukGKWhznwsi4fYwe1RrN0+QIbJyJAZVYJoBqskX1Qxnp1QG/GSt6PpwXdPC2ce jADktWerfQ2t4DAAu9aEBwN4xlgPsJ41qs8Q9sKLFmBS7IPBiwbQqetUJm5mQQmGSfgG Wzx1f/Z2T5qEa4q9hWqHIVCalZ7KiZMCUHe/YP67MYH0GCiJdlSGyF7hxO2EevE27Vql c7Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :references:cc:to:from:subject:dkim-signature; bh=7W9Fc0fF86WyXYecPV/lI8dmSptGKk8vSEWO1VbX84s=; b=ENvsXa8/XVfEtONfelYVk8tSHR+EurXEQHjMSQ0YxIUchmApHKXDHhQ7MjMpUoaRZU cxKm7WK3GTceP26oKyKK1t5U6lABNOfuCfpQh4FIR2I19TIMtV39V+ZvicVhlY+4lPAK /dtZQjG1zyoDB7z8p0sg23+QDiNt1ncGmhLwm4AM/CBas/nyScu7n+ex45uNpFaU5XWO ckfPOGBSHNXjyrtkXwVSSPsTcIxXGePVqzQtgXMWL5CVlmBpPwFD9P25WG53h1XpseKz Z2ndahPcIAMZI78lQiBTr4M3L4FoEVigFEevFvCf09I1zUlSM4U3N4mVEZwwW/4DuLG9 YedQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VgUT5Wkw; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 21si274465pjh.151.2021.09.29.03.44.47; Wed, 29 Sep 2021 03:44:59 -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=@redhat.com header.s=mimecast20190719 header.b=VgUT5Wkw; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244928AbhI2JEz (ORCPT + 99 others); Wed, 29 Sep 2021 05:04:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26352 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244898AbhI2JEy (ORCPT ); Wed, 29 Sep 2021 05:04:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632906193; 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=7W9Fc0fF86WyXYecPV/lI8dmSptGKk8vSEWO1VbX84s=; b=VgUT5Wkwz6V88ZQWns3PibHMln4HGhgp//Lqv9xtWWLTUU31B+jaqn1HXLjgQC/QydaJh8 NDkadZGDpMr/7/xCagBYELPHCNxaXtcFe2exkJT+esc+RwifmAL59hZ6W7hNVbT8JgYUIs S8u2Og2LtVssz/7JezgZKEYnn+I6IDY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-j5gX-FlrNEa_X-s5qUg9ww-1; Wed, 29 Sep 2021 05:03:12 -0400 X-MC-Unique: j5gX-FlrNEa_X-s5qUg9ww-1 Received: by mail-wr1-f70.google.com with SMTP id c2-20020adfa302000000b0015e4260febdso383514wrb.20 for ; Wed, 29 Sep 2021 02:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=7W9Fc0fF86WyXYecPV/lI8dmSptGKk8vSEWO1VbX84s=; b=EqQmJS2a/7hfAJAiMG9GQax3whgIM4iHbaBRgyA8wPMTQNidhQ9UIqPlC5T9KdxWVL sGL3Zcq2elmrgXuYYI70DfRjCHsWL/6UiVjZoAmAq/mkc5C1WA1rHLAKMNoGHqf2TeTP K3MRjEJ717hmh4xlbrkm6Gt3rRHbo03gOkM1bsuMPcHxlMua5TajVaTvCrzZaOKdZNbl lv4qvXXeVN/QcWRQLgkYVFflIKtwLQC3+s8810r81K86A9zV6c6lWSHzg0gcLRYD81F7 JMI57rmoq+9BaU0qTK+swm3mvYTC3CRpJXCST8sW/Z4qJea2ZrzunxdqTtCJC2picqQz vjQQ== X-Gm-Message-State: AOAM531xMPLc3cAwXbbs3G+oxYB7hkfKZwwcAzUgyZwOIaW0TfwcMn64 KZpSIcnaVn1hDBXO8aM+LwFL4rKLCf52m0eBtlYKhrDHDh9Z3X2EBK8f/7+6Gm0iKA5xjE2nfl8 IP0bHdAEf2JVDSe0jevZn43od X-Received: by 2002:a7b:c219:: with SMTP id x25mr9238899wmi.125.1632906190953; Wed, 29 Sep 2021 02:03:10 -0700 (PDT) X-Received: by 2002:a7b:c219:: with SMTP id x25mr9238872wmi.125.1632906190770; Wed, 29 Sep 2021 02:03:10 -0700 (PDT) Received: from [192.168.3.132] (p4ff23c3b.dip0.t-ipconnect.de. [79.242.60.59]) by smtp.gmail.com with ESMTPSA id t11sm1548498wrz.65.2021.09.29.02.03.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 02:03:10 -0700 (PDT) Subject: Re: [PATCH v1 2/8] x86/xen: simplify xen_oldmem_pfn_is_ram() From: David Hildenbrand To: Boris Ostrovsky , linux-kernel@vger.kernel.org Cc: Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Juergen Gross , Stefano Stabellini , "Michael S. Tsirkin" , Jason Wang , Dave Young , Baoquan He , Vivek Goyal , Michal Hocko , Oscar Salvador , Mike Rapoport , "Rafael J. Wysocki" , x86@kernel.org, xen-devel@lists.xenproject.org, virtualization@lists.linux-foundation.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20210928182258.12451-1-david@redhat.com> <20210928182258.12451-3-david@redhat.com> <4ab2f8c2-c3d5-30b3-a670-a8b38e218b6e@oracle.com> Organization: Red Hat Message-ID: Date: Wed, 29 Sep 2021 11:03:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.09.21 10:45, David Hildenbrand wrote: >> >> How about >> >>     return a.mem_type != HVMMEM_mmio_dm; >> > > Ha, how could I have missed that :) > >> >> Result should be promoted to int and this has added benefit of not requiring changes in patch 4. >> > > Can we go one step further and do > > > @@ -20,24 +20,11 @@ static int xen_oldmem_pfn_is_ram(unsigned long pfn) > struct xen_hvm_get_mem_type a = { > .domid = DOMID_SELF, > .pfn = pfn, > + .mem_type = HVMMEM_ram_rw, > }; > - int ram; > > - if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a)) > - return -ENXIO; > - > - switch (a.mem_type) { > - case HVMMEM_mmio_dm: > - ram = 0; > - break; > - case HVMMEM_ram_rw: > - case HVMMEM_ram_ro: > - default: > - ram = 1; > - break; > - } > - > - return ram; > + HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a); > + return a.mem_type != HVMMEM_mmio_dm; > } > #endif > > > Assuming that if HYPERVISOR_hvm_op() fails that > .mem_type is not set to HVMMEM_mmio_dm. > Okay we can't, due to "__must_check" ... -- Thanks, David / dhildenb