Received: by 10.223.176.46 with SMTP id f43csp590233wra; Sat, 20 Jan 2018 00:44:05 -0800 (PST) X-Google-Smtp-Source: AH8x225Jzw0LQAfrYdv26kRHotvESZQ7m1K1sIQCihmNW1rlEZzfox69a5dkD+jf7T2nL74HwxCo X-Received: by 10.98.212.26 with SMTP id a26mr1571389pfh.38.1516437845615; Sat, 20 Jan 2018 00:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516437845; cv=none; d=google.com; s=arc-20160816; b=XymuvzoxbK9jKh4zOZ6zsrPMGmhzvdgpw7g2ce5pb5GMwGzTxG/cBVc3TYuMlTIwOn 3BK2DFTZHZmzLbnQ9WN3gOgBAl4kaU03a+8rTwgAZ0LpQLwyLentD2dpxiJBbd6D9kEM YqXy5BKRW8LBn+/T6yaSzrxwgTa5vwHkgzl6EPyt0VoyXGzm0VSp5AbkXqevsq5DPk1D KcKKntOXctxaKeUFuNB1ML8wKDRd+Cpa6Ub9Wg3h3OOLk/clju5VVJO8p33aVNPAHwDU 0hqF1JJX7L7Gb83KM0Cngwj6pNQiv76+8fX3a66dH1PTv8xspUYwYWUhTmOcEYZlurLi 5Rww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=ujT+fhoL8CZHT1tBSadf6cEZDoe3vUwUk1ZqUxAfeMY=; b=fR/GJzEFf87n1D8mEat6FJGiMwTOmxZg1SN4EK096zgsmRaU7JAgm/iE59ujkJEHh0 cxjBGXzbtVniIGe8Vb0ZYR97YW4tdnsqvyLzySgH4htpW+xj7IYvJSZqAlza0H4+qHcr SZuRRXvXXPnnDDzm0DhlYcwUAR3d+SnxcWWTJlPR9SQJDNALkylJJ6aNBatbziIWwNUk /m3NzIi6iff/tz69Cc22+H/MbGsJGSy8k/ok5RJ4Orx5vfnzwILfWIXJVsyVP7WXeaqR tHHPA0zhA0NzoLQdVDE5gxjEgq4/goCbHr0K6YcnRWZbiuM9VoijD6llgRrXJtg37gKT 5tZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=AEyP5xmq; dkim=pass header.i=@codeaurora.org header.s=default header.b=hqhiQVMr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si9073575pgc.143.2018.01.20.00.43.51; Sat, 20 Jan 2018 00:44:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=AEyP5xmq; dkim=pass header.i=@codeaurora.org header.s=default header.b=hqhiQVMr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754151AbeATIl4 (ORCPT + 99 others); Sat, 20 Jan 2018 03:41:56 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:51278 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbeATIlt (ORCPT ); Sat, 20 Jan 2018 03:41:49 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B84FA60A60; Sat, 20 Jan 2018 08:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516437708; bh=ILQrbuENtH3CckuGiOQHc4sh+GshfN3OXgCVRI4W5QE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AEyP5xmqavwDUCE8y2EBz9YqdHJcAgbwawvQOzbcfkfAwGi/ZCjNYWuks4XNB2ekh dD4m2s+sItge96BB/vGoTFOC2IYvw/fiJhfbY8fugySfGO3kUwQVrSkYdpNX1eiB+N +uJdD+F6CjmNVC2tgb2FgOCd2DTwnm7yaamSfgag= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: pkondeti@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C8F7F6050D; Sat, 20 Jan 2018 08:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516437707; bh=ILQrbuENtH3CckuGiOQHc4sh+GshfN3OXgCVRI4W5QE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hqhiQVMr89bra6whEmtWRFz5a4kwSMnNRY79cDZl+okFePfuOck2P4yisJMEucyj9 MvVQ6dEBY6PfYWZf2Go91lYoT91Qnhz97JQm9RyoeSBmQ0JzMNVZmaAPWJAg/8XTq0 aFscZsDAPXHucK6WgoMJpvaKzOU89TNBSwm+AeG0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C8F7F6050D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pkondeti@codeaurora.org Date: Sat, 20 Jan 2018 14:11:39 +0530 From: Pavan Kondeti To: Frederic Weisbecker Cc: LKML , Levin Alexander , Peter Zijlstra , Mauro Carvalho Chehab , Linus Torvalds , Hannes Frederic Sowa , "Paul E . McKenney" , Wanpeng Li , Dmitry Safonov , Thomas Gleixner , Andrew Morton , Paolo Abeni , Radu Rendec , Ingo Molnar , Stanislaw Gruszka , Rik van Riel , Eric Dumazet , David Miller Subject: Re: [RFC PATCH 2/4] softirq: Per vector deferment to workqueue Message-ID: <20180120084139.GA8395@codeaurora.org> References: <1516376774-24076-1-git-send-email-frederic@kernel.org> <1516376774-24076-3-git-send-email-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516376774-24076-3-git-send-email-frederic@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Frederic, On Fri, Jan 19, 2018 at 04:46:12PM +0100, Frederic Weisbecker wrote: > Some softirq vectors can be more CPU hungry than others. Especially > networking may sometimes deal with packet storm and need more CPU than > IRQ tail can offer without inducing scheduler latencies. In this case > the current code defers to ksoftirqd that behaves nicer. Now this nice > behaviour can be bad for other IRQ vectors that usually need quick > processing. > > To solve this we only defer to threading the vectors that got > re-enqueued on IRQ tail processing and leave the others inline on IRQ > tail service. This is achieved using workqueues with > per-CPU/per-vector worklets. > > Note ksoftirqd is not yet removed as it is still needed for threaded IRQs > mode. > > +static void do_softirq_workqueue(u32 pending) > +{ > + struct softirq *softirq = this_cpu_ptr(&softirq_cpu); > + struct softirq_action *h = softirq_vec; > + int softirq_bit; > + > + pending &= ~softirq->pending_work_mask; > + > + while ((softirq_bit = ffs(pending))) { > + struct vector *vector; > + unsigned int vec_nr; > + > + h += softirq_bit - 1; > + vec_nr = h - softirq_vec; > + softirq->pending_work_mask |= BIT(vec_nr); > + vector = &softirq->vector[vec_nr]; > + schedule_work_on(smp_processor_id(), &vector->work); > + h++; > + pending >>= softirq_bit; > + } > +} > + I have couple questions/comments. (1) Since the work is queued on a bounded per-cpu worker, we may run into a deadlock if a TASKLET is killed from another work running on the same bounded per-cpu worker. For example, (1) Schedule a TASKLET on CPU#0 from IRQ. (2) Another IRQ comes on the same CPU and we queue a work to kill the TASKLET. (3) The TASKLET vector is deferred to workqueue. (4) We run the TASKLET kill work and wait for the TASKLET to finish, which won't happen. We can fix this by queueing the TASKLET kill work on an unbounded workqueue so that this runs in parallel with TASKLET vector work. Just wanted to know if we have to be aware of this *condition*. (2) Ksoftirqd thread gets parked when a CPU is hotplugged out. So there is a gaurantee that the softirq handling never happens on another CPU. Where as a bounded worker gets detached and the queued work can run on another CPU. I guess, some special handling is needed to handle hotplug. Thanks, Pavan -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.