Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp682894pxu; Wed, 7 Oct 2020 13:03:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxe69+3ta/dmKL49PVzyfnir7fKqgS8KWSTIws2v3oHiPyploDeRdBvZ1ooH1D84JR9Z3Z X-Received: by 2002:a17:906:bc57:: with SMTP id s23mr2906217ejv.94.1602101021400; Wed, 07 Oct 2020 13:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602101021; cv=none; d=google.com; s=arc-20160816; b=XFKooXlXwjOS8mDpb7TEtuJzCwBeCTLaqMgqsIpb7AhBn3+KkWhRBT/3PO/7NFDcSy /RMnMZMK+zIbjRPMCVswpRz1sNAwfRVhMESMCjGM5/b0VUONCS39stexGjXSwbjj/th3 l6e1U68uvNRlRI+vJ13z9J0GCk9QRq3OspWgWUZOsfF5tqxSdHLInUsP4XykpotMNCRh 06E5cLq/G5r0LblhVwY8Q9qrxErV6dDa22XR5b9yiLYkrUNAiRtEqqShNS2HtHZ7/+ed tgRCR3WhGoy7VvDAK+JVeM13esIs0XDrWr3UzPWgtHe9IZMNzTA6PEAWN0SK+csdeYNq TG+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=tJHOA1aUWoX6O6wGQCtGFkfQtlDVYwv/YvKhgXIEBs4=; b=e5aI+kdWFcaog/WQzxvaMg9H/3i19NwBoPKQZTX8OmnkbiU2W4r59pfIQCTLLvkuWQ ZPhU3P9nSiIugcHpC7EOIFYyrBjG+QvqQWMsu4aq7CLDM2eksRzTE8Vhe5/Pe3TUK7vI 1M9c/xB146RAhrkxt6qqq/KyHMRsmP4dm5Gcrom6TvPxlb2+vuRTPs+RA1eedYz1OYiZ lzN5IC1FJTgPzcM22ETvylJuTCM/JtIddrhq4RR6aIea9QysJWtwYidyiy5CFi41SNku o+OwkwPI9WNmtUkJOf0YsgH1XQYD110GI4BZq53so2Pe4I8XVH9/i7ol+sKmcTMsgsd9 wtDA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si2501947ejb.290.2020.10.07.13.03.18; Wed, 07 Oct 2020 13:03:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbgJGT3q (ORCPT + 99 others); Wed, 7 Oct 2020 15:29:46 -0400 Received: from netrider.rowland.org ([192.131.102.5]:46931 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726129AbgJGT3q (ORCPT ); Wed, 7 Oct 2020 15:29:46 -0400 Received: (qmail 469787 invoked by uid 1000); 7 Oct 2020 15:29:45 -0400 Date: Wed, 7 Oct 2020 15:29:45 -0400 From: Alan Stern To: Andrey Konovalov Cc: Dmitry Vyukov , Andrew Morton , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Shuah Khan , Alexander Potapenko , Marco Elver , Aleksandr Nogikh , Nazime Hande Harputluoglu Subject: Re: [PATCH] kcov, usb, vhost: specify contexts for remote coverage sections Message-ID: <20201007192945.GB468921@rowland.harvard.edu> References: <8c71349c3cd9698b8edcfbfc9631c5dcc3b29a37.1602091732.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8c71349c3cd9698b8edcfbfc9631c5dcc3b29a37.1602091732.git.andreyknvl@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 07, 2020 at 07:30:51PM +0200, Andrey Konovalov wrote: > Currently there's a KCOV remote coverage collection section in > __usb_hcd_giveback_urb(). Initially that section was added based on the > assumption that usb_hcd_giveback_urb() can only be called in interrupt > context as indicated by a comment before it. > > As it turns out, it's actually valid to call usb_hcd_giveback_urb() in task > context, provided that the caller turned off the interrupts; USB/IP actually > does that. This can lead to a nested KCOV remote coverage collection > sections both trying to collect coverage in task context. This isn't > supported by KCOV, and leads to a WARNING. > > The approach this patch takes is to annotate every call of kcov_remote_*() > callbacks with the context those callbacks are supposed to be executed in. > If the current context doesn't match the mask provided to a callback, > that callback is ignored. KCOV currently only supports collecting remote > coverage in two contexts: task and softirq. > > As the result, the coverage from USB/IP related usb_hcd_giveback_urb() calls > won't be collected, but the WARNING is fixed. > > A potential future improvement would be to support nested remote coverage > collection sections, but this patch doesn't address that. > > Signed-off-by: Andrey Konovalov > --- > --- a/drivers/usb/core/hcd.c > +++ b/drivers/usb/core/hcd.c > @@ -1646,9 +1646,9 @@ static void __usb_hcd_giveback_urb(struct urb *urb) > > /* pass ownership to the completion handler */ > urb->status = status; > - kcov_remote_start_usb((u64)urb->dev->bus->busnum); > + kcov_remote_start_usb((u64)urb->dev->bus->busnum, KCOV_CONTEXT_SOFTIRQ); > urb->complete(urb); > - kcov_remote_stop(); > + kcov_remote_stop(KCOV_CONTEXT_SOFTIRQ); This isn't right. __usb_hcd_giveback_urb() can execute in pretty much any context; its constraint is that interrupts must be disabled. Alan Stern