Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2270924pxp; Mon, 21 Mar 2022 15:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5RC+6MeAIvbiRPOJVv0K9dn/GlHfA+uKblUkbiUey2JtXgWB9TXFWhEF5qhvSckMS01tO X-Received: by 2002:a17:902:c945:b0:154:5215:1da4 with SMTP id i5-20020a170902c94500b0015452151da4mr8052287pla.169.1647901807987; Mon, 21 Mar 2022 15:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901807; cv=none; d=google.com; s=arc-20160816; b=0D1IPUTICzfC31jbbGojEGzRMHjTq7XYw5TFWSNDKQWl3byV+D1n1qDOjm1RnvItM/ 57vm1X0Ce0YDT/n3lryHHq/ea1/AIebwVF0ZBoy5L5UmC4KFAjxAK856gLD45IOI9Zup KEJIVEHQmDh9yXZs3BYpd3GgbqTNOOJYSoMd/GcVC1rZ9wYj/pBUgildcyZgzK5E/GZw oCrKZ8tAt2N/HuNtTlBXD/GV/V26BiyqgRvur4oWBb0BVUXmEu47VeJmcZZvvwXgsLuS 3ocYrxsZSpkeE7TjJmw0W4/gq1rI0cPa/qDrw9wQ7tvW3Ixe3/pkRJgm623XzmVTwlFm 1rLA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8GTIMWQve+g7wKIIsMEJALGjWCTbDmifDv5C0pWR1mM=; b=Q2/ZIThbD2PSMOu0R8HN2maW8hvtCIehJ7tRIBowXkSsFQOE0sHKsgRu5z6H+1fwrI DqhWf9RU9JFOh8v/8pgWHpH303FFnl4qD3cfbJrhgS/Syg/GudsbiA2twYP2yVILQIX7 7mHTfLExmB8ZWizi7ED4b6Ki364ioEl2mAPINcckQYSUbijXwB8uqHzZ2K3JEBqz/IhF VdWKPyUOp1c0rYSvmvvQ8/vAcrUGGsOOPP24nvDnKSwdp9w5gyB475god6GDjgp5pRbR nMfyMDDEoc8FiUHC18A1PD6BqrHpkOJ09tSzZC7ZSPVcbvUPlAQpgh17cqZrE3JkAOHN 87EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=a5xvYHlv; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k189-20020a636fc6000000b003816043eed6si14563771pgc.203.2022.03.21.15.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:30:07 -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=@gmail.com header.s=20210112 header.b=a5xvYHlv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88B783AA168; Mon, 21 Mar 2022 14:43:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243554AbiCSQBB (ORCPT + 99 others); Sat, 19 Mar 2022 12:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbiCSQBA (ORCPT ); Sat, 19 Mar 2022 12:01:00 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B47219A561; Sat, 19 Mar 2022 08:59:38 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id d10so22212355eje.10; Sat, 19 Mar 2022 08:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8GTIMWQve+g7wKIIsMEJALGjWCTbDmifDv5C0pWR1mM=; b=a5xvYHlvl3R8AQ0C3wjzNthnrBkCQ64fZ3NdgDvpeo2sYFWR7vVKJxfoSVjIaUbb91 LjBEAxQ5S5Tv6q3nZpqzXHad4YPtjl/t2UFLepYBbYvx6KKq/jfa0jZzxNllid6J/SjI oadBNva70xUediy4wrvv4SZAm67TaFAT5ngoanjGKCa8N+j7mBIaJyoMtA/oS+Or62vG siGcZpt6qslVh0wqMBcxmxvWwOVbHiORwiRgTUKDYTR+SUjKEp5JGKIBecSxrvwnefh3 t8Mbf2q8dHMSa9Vb1gqWG3vMSqxzl6y7eUu8oIwgeL2Y3hrPFhef1F9eH39mhMw69Cdu SXDw== 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:in-reply-to; bh=8GTIMWQve+g7wKIIsMEJALGjWCTbDmifDv5C0pWR1mM=; b=PmfmicZePT/7YpKtaJAAXMYeLuCatQWcvrwqx3jYz482lHeE3fN5n98amcRZ25cw1U ikkXNekxrRg8I9/psiYSqNmnrBgCAXFZBbJ/M5CB1Lh51dVM+mRgh0ocAtwsI/Kvy0LT 8QyO9mngaJ/4UkP+/ocqXY/jTiSw1nIt/ZhUQAU7vOIg1tA4BQrtx3ot0Nz5bojQikQA 13WUzIMsvanIQHSTPbcRhsVvmwqF3+rejdp2L2QHAuQB8WojpFOh9XiyePSyzFtsr+Gw itUVP/KFnnlFqHlhwcDGwPra0fIPv9coUCKaqasMinJygQqbEEhg24H7S3ncIF36vTFX 4BvQ== X-Gm-Message-State: AOAM5300M98Ngui8pjbNkbJgwr5sYFUM8cLUPtgV+zfbTPLRj7/upqhO 8+aSBUrvdlX1ZffiPJVCSvE= X-Received: by 2002:a17:906:6886:b0:6df:8b7b:499e with SMTP id n6-20020a170906688600b006df8b7b499emr13801188ejr.289.1647705576710; Sat, 19 Mar 2022 08:59:36 -0700 (PDT) Received: from anparri (host-82-59-4-232.retail.telecomitalia.it. [82.59.4.232]) by smtp.gmail.com with ESMTPSA id l9-20020a1709060cc900b006ce04bb8668sm4902499ejh.184.2022.03.19.08.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Mar 2022 08:59:36 -0700 (PDT) Date: Sat, 19 Mar 2022 16:59:28 +0100 From: Andrea Parri To: Saurabh Singh Sengar Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , "Michael Kelley (LINUX)" , Wei Hu , Lorenzo Pieralisi , Rob Herring , Krzysztof Wilczynski , Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [EXTERNAL] [PATCH 1/2] PCI: hv: Use IDR to generate transaction IDs for VMBus hardening Message-ID: <20220319155928.GA2951@anparri> References: <20220318174848.290621-1-parri.andrea@gmail.com> <20220318174848.290621-2-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 > > @@ -1208,6 +1211,27 @@ static void hv_pci_read_config_compl(void > > *context, struct pci_response *resp, > > complete(&comp->comp_pkt.host_event); > > } > > > > +static inline int alloc_request_id(struct hv_pcibus_device *hbus, > > + void *ptr, gfp_t gfp) > > +{ > > + unsigned long flags; > > + int req_id; > > + > > + spin_lock_irqsave(&hbus->idr_lock, flags); > > + req_id = idr_alloc(&hbus->idr, ptr, 1, 0, gfp); > > [Saurabh Singh Sengar] Many a place we are using alloc_request_id with GFP_KERNEL, which results this allocation inside of spin lock with GFP_KERNEL. That's a bug. > Is this a good opportunity to use idr_preload ? I'd rather fix (and 'simplify' a bit the interface) by doing: static inline int alloc_request_id(struct hv_pcibus_device *hbus, void *ptr) { unsigned long flags; int req_id; spin_lock_irqsave(&hbus->idr_lock, flags); req_id = idr_alloc(&hbus->idr, ptr, 1, 0, GFP_ATOMIC); spin_unlock_irqrestore(&hbus->idr_lock, flags); return req_id; } Thoughts? Thanks, Andrea