Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1793142pxk; Sat, 26 Sep 2020 05:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWfIvObj6wk4a+FHDvJdTKN2CDU9ZSRbl85oj6rHYBm/tPWb8+gaKqypH2EkB07T7JGcH3 X-Received: by 2002:aa7:d4d0:: with SMTP id t16mr6362945edr.83.1601123038453; Sat, 26 Sep 2020 05:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601123038; cv=none; d=google.com; s=arc-20160816; b=TLxMhYo82Saehqo0hzb9U+v98U9kitNijU8aPw9kN4Mh8wivgY37hp3PZ7U6lvCWkC fAG15VDfIQ+uPWbeJ1y6dZvUVPQZHAG2gyuJnjwp0NCFStv/0yXMvH3xADy0WhR0j9ut SSWdzXCoqWNuw4aq/T9hf3/XCwrWCEuOlaXtMjRKRxQ3c/sq0P+p5fiPDf0gW2Nk8M+2 tIyA1yQxyFAWH0W1OxaU6RFlaQFAeSQBWqQV4C0V0qxMFerDrYu4qPlVsqlFXbe8s2p5 /9yZKYd4wmOBLF8YSqhdPwqN/uXFF6PaaUXnVkp2zVAYbSItmXNT4ic8n/8lVNt8Odpn Vm+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 :dkim-signature; bh=kGnzDqV9KAQcPIEAwOTQQ+8DXLf5Y2dkaZ8KJ1Ninr8=; b=yZ/7jqzt9bGmLQrM8VE6zicU5nFGVw5Ny56dsWHG+59/neo3RoKBZ8/9QP10SdldJv pakA6lA7SlYg8c2qjfP/C6M5K0BET90Kz6o0kFWN+KjFBSTguFXttITpqrsjy9gt71v9 3VzZmbfY/ZlLqMjUjGea8sxQGTwOdPq6sqPLEH591reN4Iw0fzu3L1oAhaMhni02qsIr yFIiuU1K2CciJGaJ9ysNDFtlBQEUCYfDetYaO+cMXRrLhY1XxCX/+UoeQPpB7p0WWIhd SoxtRtCKnlVDSYvEFJee23XgS+TnD0YNfaiumeBlFVmknqfCRImVqtSbf/KyxaPhfnQx kc0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="G9/rcOxD"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si4075465edt.158.2020.09.26.05.23.34; Sat, 26 Sep 2020 05:23:58 -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=@kernel.org header.s=default header.b="G9/rcOxD"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726244AbgIZMWY (ORCPT + 99 others); Sat, 26 Sep 2020 08:22:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:51506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgIZMWX (ORCPT ); Sat, 26 Sep 2020 08:22:23 -0400 Received: from localhost (lfbn-ncy-1-588-162.w81-51.abo.wanadoo.fr [81.51.203.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CEBA2238E6; Sat, 26 Sep 2020 12:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601122943; bh=006xBjR82/BKPE/0UZL1e7DnAaSXPsvHWZB2ii5OHRU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G9/rcOxD3HnEPIxfBmym1/0xY+YLsFoiMYzuw+IeqQXV79VFa/aKFDwF0frrZFodq MVG04PGkGfuvlwEq8+dQ9Ss0/rTdcIA+UAd3jwNRZc6kQQCCi/3AJubzOyECcLWPnO 3tMbTlK33QSt+C67qew3E5V3m56OoiI7H0bCn7JY= Date: Sat, 26 Sep 2020 14:22:20 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: qianjun.kernel@gmail.com, peterz@infradead.org, will@kernel.org, luto@kernel.org, linux-kernel@vger.kernel.org, laoar.shao@gmail.com, qais.yousef@arm.com, urezki@gmail.com Subject: Re: [PATCH V7 4/4] softirq: Allow early break the softirq processing loop Message-ID: <20200926122220.GA10735@lenoir> References: <20200915115609.85106-1-qianjun.kernel@gmail.com> <20200915115609.85106-5-qianjun.kernel@gmail.com> <878scz89tl.fsf@nanos.tec.linutronix.de> <20200925004207.GE19346@lenoir> <874knlv5pq.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874knlv5pq.fsf@nanos.tec.linutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 26, 2020 at 12:42:25AM +0200, Thomas Gleixner wrote: > On Fri, Sep 25 2020 at 02:42, Frederic Weisbecker wrote: > > > On Thu, Sep 24, 2020 at 05:37:42PM +0200, Thomas Gleixner wrote: > >> Subject: softirq; Prevent starvation of higher softirq vectors > > [...] > >> + /* > >> + * Word swap pending to move the not yet handled bits of the previous > >> + * run first and then clear the duplicates in the newly raised ones. > >> + */ > >> + swahw32s(&cur_pending); > >> + pending = cur_pending & ~(cur_pending << SIRQ_PREV_SHIFT); > >> + > >> for_each_set_bit(vec_nr, &pending, NR_SOFTIRQS) { > >> int prev_count; > >> > >> + vec_nr &= SIRQ_VECTOR_MASK; > > > > Shouldn't NR_SOFTIRQS above protect from that? > > It does, but that's wrong. The bitmap size in that for_each() loop must > obviously be SIRQ_PREV_SHIFT + NR_SOFTIRQS for this to work. Ah! I see, I thought you were ignoring the high bits on purpose, hence my questions after about pending. > > >> + } else { > >> + /* > >> + * Retain the unprocessed bits and swap @cur_pending back > >> + * into normal ordering > >> + */ > >> + cur_pending = (u32)pending; > >> + swahw32s(&cur_pending); > >> + /* > >> + * If the previous bits are done move the low word of > >> + * @pending into the high word so it's processed first. > >> + */ > >> + if (!(cur_pending & SIRQ_PREV_MASK)) > >> + cur_pending <<= SIRQ_PREV_SHIFT; > > > > If the previous bits are done and there is no timeout, should > > we consider to restart a loop? > > We only enter this code path if there was a timeout. Otherwise pending > would be 0. Right with SIRQ_PREV_SHIFT + NR_SOFTIRQS now that whole makes sense! Thanks!