From owner-freebsd-current@freebsd.org Mon Feb 8 10:52:38 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 0A819AA17D6 for ; Mon, 8 Feb 2016 10:52:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) 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 E2C58F17 for ; Mon, 8 Feb 2016 10:52:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id E35FFAA17D5; Mon, 8 Feb 2016 10:52:37 +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 C8FE9AA17D4 for ; Mon, 8 Feb 2016 10:52:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7306AF16 for ; Mon, 8 Feb 2016 10:52:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u18AqUla059652 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 8 Feb 2016 12:52:31 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u18AqUla059652 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u18AqUsK059651; Mon, 8 Feb 2016 12:52:30 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 8 Feb 2016 12:52:30 +0200 From: Konstantin Belousov To: Oliver Pinter Cc: current Subject: Re: Broken suspend-resume (suspend to RAM) with enabled INVARIANTS on 11-CURRENT - with workaround Message-ID: <20160208105230.GG91220@kib.kiev.ua> References: <20160206152345.GW91220@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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: Mon, 08 Feb 2016 10:52:38 -0000 On Sun, Feb 07, 2016 at 10:59:48PM +0100, Oliver Pinter wrote: > On 2/6/16, Konstantin Belousov wrote: > > On Fri, Feb 05, 2016 at 07:34:02PM +0100, Oliver Pinter wrote: > >> Not yet tested, but possible fix: > >> > >> diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c > >> index cb952da..25bae84 100644 > >> --- a/sys/kern/init_main.c > >> +++ b/sys/kern/init_main.c > >> @@ -482,7 +482,7 @@ proc0_init(void *dummy __unused) > >> session0.s_leader = p; > >> > >> p->p_sysent = &null_sysvec; > >> - p->p_flag = P_SYSTEM | P_INMEM; > >> + p->p_flag = P_SYSTEM | P_INMEM | P_KTHREAD; > >> p->p_flag2 = 0; > >> p->p_state = PRS_NORMAL; > > So did you tested this ? Did you do an audit to see whether P_KTHREAD > > other usages possibly conflict with the proc0 specifics ? > > Tested and working as expected. In fact, I do not want to mark proc0 as P_KTHREAD. This would allow the kthread_suspend() on the proc0, and I did not audited uses of the KPI to guarantee the effect, also I am not sure about third-party code which could have relied on kthread_suspend() rejecting proc0. I do agree that the assert outlived its usefulness. I restructured the comments to put it before stop_all_proc() and removed the assert, together with disabling the compilation of sysctl_debug_stop_all_proc(). > Other uses would not conflict, since the codes already checks for > P_SYSTEM and the P_KTHREAD flag is almost kern_kthread.c's "private" > flag. > > And this change probably fixes one issue with hwpmc too, in the kernel case: > > -- > dev/hwpmc/hwpmc_mod.c- > dev/hwpmc/hwpmc_mod.c- /* issue an attach event to a configured log file */ > dev/hwpmc/hwpmc_mod.c- if (pm->pm_owner->po_flags & PMC_PO_OWNS_LOGFILE) { > dev/hwpmc/hwpmc_mod.c: if (p->p_flag & P_KTHREAD) { > dev/hwpmc/hwpmc_mod.c- fullpath = kernelname; > dev/hwpmc/hwpmc_mod.c- freepath = NULL; > dev/hwpmc/hwpmc_mod.c- } else { > dev/hwpmc/hwpmc_mod.c- pmc_getfilename(p->p_textvp, > &fullpath, &freepath); > dev/hwpmc/hwpmc_mod.c- pmclog_process_pmcattach(pm, > p->p_pid, fullpath); > dev/hwpmc/hwpmc_mod.c- } What is wrong with this code ? proc0 has NULL p_textvp, so the call to pmc_getfilename() does not do anything except setting pointers to NULL.