From owner-svn-src-head@FreeBSD.ORG Thu May 3 13:14:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37E89106564A; Thu, 3 May 2012 13:14:23 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 761638FC14; Thu, 3 May 2012 13:14:22 +0000 (UTC) Received: by vbmv11 with SMTP id v11so1650558vbm.13 for ; Thu, 03 May 2012 06:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=7uzJ8xgsPVtntvkCdfcB7L4yRXAV3MCDruYTzC4GA8M=; b=bxc02wTT8tCWdOzWNZtqbtG8hMp041pGRC3olzbk6S82TPhglR6v5EHD9CXDIoaGl0 8A48h8R9/gdF1eZCtS2P3ZNbTcoabFLR0iKpEqxuYCB3G8GDip7zM1doZ0lExkQ1MlsL C//6Pe0VXe16iJ+Z71J2tshe31az/wUkNNCtclB94mpunFyVe22Q4YStvSCgpefD9PdW q0Uy7QDw0A1/IvTwxcX2gI9/dR6SLMlPoxOEKlep9oNf4TiafUEPKKNayglDpUMX877y gfxGcI/qCvaaBrWlK5vK4aOzOLmSIbNdhd9joSFDlUGGb/swNj5MyknhlLUwPQJNRUM0 xUdA== MIME-Version: 1.0 Received: by 10.52.23.70 with SMTP id k6mr979335vdf.86.1336050861664; Thu, 03 May 2012 06:14:21 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.220.38.72 with HTTP; Thu, 3 May 2012 06:14:20 -0700 (PDT) In-Reply-To: <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 14:14:20 +0100 X-Google-Sender-Auth: wCNjRFQNGd-4CgDcioS5uUctlTc Message-ID: From: Attilio Rao To: Konstantin Belousov , christian.esken@trivago.com Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:14:23 -0000 2012/5/3, Konstantin Belousov : > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> 2012/5/3, Konstantin Belousov : >> > Author: kib >> > Date: Thu May 3 10:38:02 2012 >> > New Revision: 234952 >> > URL: http://svn.freebsd.org/changeset/base/234952 >> > >> > Log: >> > When callout_reset_on() cannot immediately migrate a callout since it >> > is running on other cpu, the CALLOUT_PENDING flag is temporarily >> > cleared. Then, callout_stop() on this, in fact active, callout fails >> > because CALLOUT_PENDING is not set, and callout_stop() returns 0. >> > >> > Now, in sleepq_check_timeout(), the failed callout_stop() causes the >> > sleepq code to execute mi_switch() without even setting the wmesg, >> > since the switch-out is supposed to be transient. In fact, the thread >> > is put off the CPU for full timeout interval, instead of being put on >> > runq immediately. Until timeout fires, the process is unkillable for >> > obvious reasons. >> > >> > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION >> > flag. The flag is cleared by callout_stop_safe() when the function >> > detects a migration, besides returning the success. The softclock() >> > rechecks the flag for migrating callout and cancels its execution if >> > the flag was cleared meantime. >> >> Can you please clarify why you cannot simply drop the deferred >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > > I probably can, I think I went with the route of committed patch > because it is slightly less work. Also, the comment in the while() > loop suggested me to rely on softclock. I don't think this is more work at all, the attached patch (pre-r234952, untested) should address it properly in few than 10 lines: http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch without the need to add further flags and re-using existing mechanisms. Attilio -- Peace can only be achieved by understanding - A. Einstein