Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp32480imm; Thu, 4 Oct 2018 15:55:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV63639vgsBUG+3AFTGI6wqzh+BDE7A3yjlIt2WmKV3hp98bL3Dpl55OEUEUlxosx5MHVWumb X-Received: by 2002:a63:7744:: with SMTP id s65-v6mr7575314pgc.197.1538693722808; Thu, 04 Oct 2018 15:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538693722; cv=none; d=google.com; s=arc-20160816; b=nXJ2sBbO4QtJQxv3ql/ghq7pkwMQLpe9/AQFjapj4x7s6MykGYkBTBAvc4i7hnofot BMkMKKVTH3hnk9kbMguTKrO9VQ1uO+Tntc0OEMd07KpAnTMJNb/ZQfffsVgAERkuEfea kgYegA8kOLbdPBa2Qgx/A5qimWyNrnRpeKwOQO9Dl4vapENKN9k7NZTEgHseFerIoHe7 07p52bUrwL0nbQDHxSV9eCrwr1hcj0nYLkTKFqo/cbmMtKvFC471iiAj/8LdY+Pun9dX QwlOLJDnCfjqnaxrI9uVDxKMEdByGj4HuYIGDPmQK7IcfqsCRq28i4mmjpcNslK5B98F kXow== 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:dkim-signature; bh=oUCuOszvOFqzUM8ixvg4fz6Wi0TCsbgm64iOKKej0Nk=; b=bV8pk0oSE2WLry+f/+9AxK6aUdVkEQieBHv3dGcdFEDc2kJO8szNnKEB96dxU9d/ll tMJKsmpnPHSsDEEmOzaUV/M0uqqQUhSxGAK1nf+XcfVeiETYQVFatZY7ekraHHirhas+ hyuiR5kr+kTo2d/DCV029k5BC2lVLY97lqqOM06mosMbobxFGFaYRtK5Lw3qKIrD2bQD eAU0l4gjnm0s05Fq1BKlCG4A4vnYbRyAQ6NCqHKIUwFFxToFFK+6I67IzGZK+gjou+P3 0izxvj2WxzbaChK5ZcFt2zj/+XEGSuBaQco75dF6p9w9UK0KgTxQMsR3G9vmTiwnvKxI qLdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="e5L+j/fw"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si6991325pld.322.2018.10.04.15.55.06; Thu, 04 Oct 2018 15:55:22 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="e5L+j/fw"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbeJEFui (ORCPT + 99 others); Fri, 5 Oct 2018 01:50:38 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42983 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeJEFui (ORCPT ); Fri, 5 Oct 2018 01:50:38 -0400 Received: by mail-pg1-f195.google.com with SMTP id i4-v6so3810132pgq.9; Thu, 04 Oct 2018 15:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oUCuOszvOFqzUM8ixvg4fz6Wi0TCsbgm64iOKKej0Nk=; b=e5L+j/fwuID4d2KXPAl7SJ2dLCC3ihDpREEfxtKrQw1faijN8tk4sFJeuaH8TulCPG tSGcgr+teQHH/eDSaJCWLZz2Zyz9SfdkR7l5b+WJXB3asTbBRVuEwml+pxfKMFmkOgNo 8CB9BHjOv50+TvAWLbAZPXZZij2qRN+T2e1ahva+vNFe3mqq+7S1RB12KOlu2ezSEbN5 nDgf2xIGXdzhc0gm9Ze+TRorQwffr0WDyItCAX10netcLdfZMcceUUvVXXAPYsqdie1w vfJoAcYXmgBHO9TrcMZv1rjX5cFTaV1ttsaLo9YA/TdaJFHQlrs28iMgH95v9U9hqZFj Gzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oUCuOszvOFqzUM8ixvg4fz6Wi0TCsbgm64iOKKej0Nk=; b=f7XXcIxYTjlOr1CB01YzVkNl41zsOiZSnwnztfhCDVF6shTI7qHP1ZF4THcjsfZT2n xQhK2j+WVDvEefHmqVX9lhCELCCbRHVTuSvHOZ1l/tVdh205eIHDNG7PGY1yMIvywaZJ cVXfSDVRn3IH6J4TnNwqVLo8wOKycADwqaySF+MOzp144egnqZkyX8nEF+OJsgqvkSL5 RY1AXUOfNY5oFgXK86sTwpR8iC4GsACkD7iEun3rM9M86jt3lUcAK8MwQCKP0/49S48p tKo3jUP6KR+nHHnB37nUt1vFX3ayqpMAWhWDFfqEmye/0s4oxx4h/PXqIGPmAjhTlKQR +qAA== X-Gm-Message-State: ABuFfohYEOA9msaKcr+Ot7KERqneh/VQmfp/8omt7pPp+1ISZOllgW2Q mYujACqX2SaHqXcVLtOXQZo= X-Received: by 2002:a62:425b:: with SMTP id p88-v6mr8930472pfa.96.1538693699147; Thu, 04 Oct 2018 15:54:59 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id q76-v6sm10592452pfa.18.2018.10.04.15.54.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Oct 2018 15:54:57 -0700 (PDT) Date: Thu, 4 Oct 2018 15:54:55 -0700 From: Dmitry Torokhov To: "Paul E. McKenney" Cc: Eric Dumazet , linux-kernel , Eric Dumazet , linux-input@vger.kernel.org Subject: Re: [PATCH] Input: mousedev - add a schedule point in mousedev_write() Message-ID: <20181004225455.GC233675@dtor-ws> References: <20181004154749.111595-1-edumazet@google.com> <20181004185949.GA233675@dtor-ws> <20181004193407.GK2674@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181004193407.GK2674@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 04, 2018 at 12:34:07PM -0700, Paul E. McKenney wrote: > On Thu, Oct 04, 2018 at 11:59:49AM -0700, Dmitry Torokhov wrote: > > Hi Eric, > > > > On Thu, Oct 04, 2018 at 08:47:49AM -0700, Eric Dumazet wrote: > > > syzbot was able to trigger rcu stalls by calling write() > > > with large number of bytes. > > > > > > Add a cond_resched() in the loop to avoid this. > > > > I think this simply masks a deeper issue. The code fetches characters > > from userspace in a loop, takes a lock, quickly places response in an > > output buffer, and releases interrupt. I do not see why this should > > cause stalls as we do not hold spinlock/interrupts off for extended > > period of time. > > > > Adding Paul so he can straighten me out... > > If you are running a !PREEMPT kernel, then you need the cond_resched() > to allow the scheduler to choose someone else to run if needed and > to let RCU know that grace periods can end. Without the cond_resched(), > if you stay in that loop long enough you will get excessive scheduling > latencies and eventually even RCU CPU stall warning splats. > > In a PREEMPT (instead of !PREEMPT) kernel, you would be right. When > preemption is enabled, the scheduler can preempt and RCU can sense > lack of readers from the scheduling-clock interrupt handler. Which > is why cond_resched() is nothingness in a PREEMPT kernel. > > But because people run !PREEMPT as well as PREEMPT kernels, if that loop > can run for a long time, you need that cond_resched(). OK, I see. I'll apply the patch then. I think evdev.c needs similar treatment as it will keep looping while there is data... Thanks. -- Dmitry