From owner-freebsd-current@freebsd.org Fri Feb 5 18:25:34 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBE9AA9DB5F for ; Fri, 5 Feb 2016 18:25:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 9F6C21F0 for ; Fri, 5 Feb 2016 18:25:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 9EF34A9DB5E; Fri, 5 Feb 2016 18:25:34 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85EAEA9DB5D for ; Fri, 5 Feb 2016 18:25:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 255131ED for ; Fri, 5 Feb 2016 18:25:34 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x232.google.com with SMTP id p63so38887259wmp.1 for ; Fri, 05 Feb 2016 10:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=WtZV78ZT2lPYa42b+KfQn+y0OP3swGKxw9jBvPUBaz0=; b=i8C7KElS9E8rQguZN6HC2tsx2ahraR3AyZynigwbudCNiKFMh2jp+vq0dNelBEuqa9 VIXdoQjY9cGCMTdgPfw4B+jhapB+rwiEro9izpibEVnl0eUncFDZtVR3xqAUme5BtGJY w4SUCIWo/6aObulLWxgm0Z4I7vm7TR1EAcCW7H2Z5HbyKeFf2pZQSgN3SSAYeikmeSM9 m7ETENKK90obLqVcUp2xuh9y2lst0v7nfeuEnMHSXeEZY/UJBcmLnmtugNkhWN2jMKky BIJpiEqjc/gLpxUxgLOKCspLEXKndOTLpOh+oiCnJUSieQPUyVk6BNMUB0pc946kmoKf QpMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=WtZV78ZT2lPYa42b+KfQn+y0OP3swGKxw9jBvPUBaz0=; b=XIOy44rCyvH115sOuRV1kxbuEtLzKfSITNWJweFHMJg/yngjzrCW8I2Rf1uMxMKc5h cZBThHWlkuyRm4K2gxB9S2bWdinUMup2ZlscxSJqvafnw5KXUPasYjeJypAEYxo7YbNi zIMk7zsF4n38ejF7hNF7BZIfzXizh/fKtZHWHKBMefyPGXwHDgdOilPU8ORG0ZkokIfA KtcXVPYZCOBACpNZi3malFiDFYSERWFmIJvnoYMvgHIOyQYN4O98WpnGqDCDhtRpN3sh YpMt08lmDA9HHi2030oSqqkCCaUJ3JAkK6ESKih5m8RJn1QIbYmq4B5ndVFtzHQvhy4A +fbQ== X-Gm-Message-State: AG10YOQJ3l9Xsrd82LFl0AJA0fzdQGKHBbOl9aPffapLapXY07dGg1xwgSsZHUakJE2pUEuk8+Z4xulR0nL3TkhU MIME-Version: 1.0 X-Received: by 10.194.3.47 with SMTP id 15mr6289034wjz.63.1454696732586; Fri, 05 Feb 2016 10:25:32 -0800 (PST) Received: by 10.194.82.6 with HTTP; Fri, 5 Feb 2016 10:25:32 -0800 (PST) Date: Fri, 5 Feb 2016 19:25:32 +0100 Message-ID: Subject: Broken suspend-resume (suspend to RAM) with enabled INVARIANTS on 11-CURRENT - with workaround From: Oliver Pinter To: current Cc: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Feb 2016 18:25:34 -0000 Hi all! I used this gdb macro, to traverse the proc list, and print out the relevant p_flag's flags: set $curr_proc=0 def next_proc if $curr_proc == 0 set $curr_proc = allproc.lh_first else set $curr_proc = $curr_proc.p_list.le_next end set $curr_p_flag = $curr_proc->p_flag set $curr_name = $curr_proc->p_comm p $curr_name p/x $curr_p_flag if ($curr_p_flag & 0x00004) != 0 printf "is P_KTHREAD\n" else printf "isn't P_KTHREAD\n" end if ($curr_p_flag & 0x00200) != 0 printf "is P_SYSTEM\n" else printf "isn't P_SYSTEM\n" end end And seems like the "kernel" process don't have the P_KTHREAD flag, which fires the KASSERT in sys/kern/kern_proc.c's stop_all_proc(void) function. The relevant part of the code is: 2986 void 2987 stop_all_proc(void) 2988 { 2989 struct proc *cp, *p; 2990 int r, gen; 2991 bool restart, seen_stopped, seen_exiting, stopped_some; 2992 2993 cp = curproc; 2994 /* 2995 * stop_all_proc() assumes that all process which have 2996 * usermode must be stopped, except current process, for 2997 * obvious reasons. Since other threads in the process 2998 * establishing global stop could unstop something, disable 2999 * calls from multithreaded processes as precaution. The 3000 * service must not be user-callable anyway. 3001 */ *3002 KASSERT((cp->p_flag & P_HADTHREADS) == 0 || *3003 (cp->p_flag & P_KTHREAD) != 0, ("mt stop_all_proc")); 3004 3005 allproc_loop: If I comment out this KASSERT or just whitelist the "kernel" process, then I get a completely working suspend to ram and resume on my laptop (which is a HP 430G1) with one additional small tweak (hw.acpi.reset_video=1). So the question is that the KASSERT is bogus or too strict, or the P_KTHREAD flags is missing from "kernel" process? The gdb macros output is: [...] (kgdb) $139 = 0xfffff800029773c8 "rand_harvestq" $140 = 0x10000204 is P_KTHREAD is P_SYSTEM (kgdb) $141 = 0xfffff80002977940 "init" $142 = 0x10004200 isn't P_KTHREAD is P_SYSTEM (kgdb) $143 = 0xfffff800029783c8 "audit" $144 = 0x10000204 is P_KTHREAD is P_SYSTEM (kgdb) $145 = 0xffffffff80f1b4d0 "kernel" $146 = 0x10000280 isn't P_KTHREAD is P_SYSTEM I've CC-ed Konstantin to this discussion, because he added this functionality to the kernel. Additional info: If I try to trigger the KASSERT with the debug.stop_all_proc=1 sysctl, then it's never fires, but when I try to put my machine to S3 with ctrl+alt+space then it fires.