From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8B9493858D39 for ; Wed, 13 Dec 2023 14:47:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B9493858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8B9493858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702478829; cv=none; b=svOihbIc+8DHlQ2Kq4wpv0HuFrroCV1rvzAGjMcQZ4xu33Bv4rWWwkRYvW3HbvONAVgel2sehlqEk0LrESr1bVlGRyTpRLhxFLSgcjcyiOKlBxABG3TGy13fQQuASlwxdebPmrfFr05mIPVip4hEz6+lkIUrUBzxRz1CXsdntLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702478829; c=relaxed/simple; bh=QT4tBYrcFZo8neuFaXAYFmCJztcLMtCDC2eonMInuJw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=BOd2dPeetOlPIvx7zKYU+qhl0zVgVevmrbH6D5tYMjD2tPIjKzNIDzdwR59zlnmnjb6BkSz9Ojys/wghVNbJF74Yu9Pfbjxlv8RxNl8OiBKzzAX5c6eXNw2GMzTkBWf/GIxlUfj7OzOcpAm0tc4yC2iqKuyqWCLzm+OrwC4l2Qo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702478827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yTJsSFL+WjRKlWeMt8kNc+BnMcpKVpQKEy3ch+mjETY=; b=ipeMahFK5Ws9iz0+4gsjKe1YBnlVmS6tEr1NDeIAos84aGtA1NOB7ITMzwgBFKSzaJIwoH 8LSNakVsTWHVV1DGHzQh1PhATSxcyi8nE267D/HDEjrm+t5Shdyf6JboXS6/gGNgRBBO6x SlFd7U+CuTSc2VeT+iYNNYV56S7cV3Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-Covmkk3TNNCosEZTRu299Q-1; Wed, 13 Dec 2023 09:47:03 -0500 X-MC-Unique: Covmkk3TNNCosEZTRu299Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3DFFC101A58F; Wed, 13 Dec 2023 14:47:03 +0000 (UTC) Received: from [10.13.129.81] (dhcp129-81.rdu.redhat.com [10.13.129.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 304BEC15E6A; Wed, 13 Dec 2023 14:47:02 +0000 (UTC) Message-ID: Date: Wed, 13 Dec 2023 09:47:02 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: wcohen@redhat.com, systemtap@sourceware.org Subject: Re: [Bug runtime/30831] Systemtap scripts fail to compile on newest linux 6.6 kernels To: Tetsuo Handa References: From: William Cohen In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------Su1ORGbqduP08doMX01rHkXq" Content-Language: en-US X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------Su1ORGbqduP08doMX01rHkXq Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/23/23 10:16, Tetsuo Handa wrote: > On 2023/09/28 5:03, wcohen at redhat dot com via Systemtap wrote: >> commit ca71442b93af61cbd9a1386e24e967373f928eae (HEAD -> master, origin/master, >> origin/HEAD) >> Author: William Cohen >> Date: Wed Sep 27 10:09:11 2023 -0400 >> >> Eliminate use of kernel's flush_scheduled_work() in systemtap modules >> >> Kernel git commit 20bdedafd2f63e0ba70991127f9b5c0826ebdb32 turns use >> of flush_scheduled_work() into a warning which causes builds of >> anything using it to fail because warnings are treated as errors. >> Previous users of flush_scheduled_work() in the kernel have been >> converted over to use individual workqueues. Systemtap runtime now >> does the same. It creates and uses its own workqueue to eliminate the >> use of flush_scheduled_work(). > Hi, Sorry for not getting to this earlier. Attached is a patch that attempts to address the problems mentioned in this email. Could you verify that the patch addresses all the concerns. > That commit does not look correct. > > systemtap_wq = alloc_workqueue("systemtap-wq", WQ_UNBOUND | WQ_MEM_RECLAIM, 0); > if (!systemtap_wq) > return !systemtap_wq; > > causes stap_init_module() to return 1 (i.e. a positive value) when alloc_workqueue() > failed. The caller ( https://elixir.bootlin.com/linux/v6.6/source/kernel/module/main.c#L2528 ) > emits a warning message but thinks that stap_init_module() succeeded. > stap_init_module() should return -ENOMEM when alloc_workqueue() failed. This area of code now return -ENOMEM if alloc_workqueue fails. It also eliminates the WQ_MEM_RECLAIM flag. > > Also, when alloc_workqueue() with WQ_MEM_RECLAIM flag succeeded, alloc_workqueue() > allocated a "struct task_struct". Not calling destroy_workqueue(systemtap_wq) leaks > that "struct task_struct" and related kernel resources. > > rc = systemtap_kernel_module_init(); > if (rc) > return rc; > > I don't know the content of systemtap_kernel_module_init() emitted by translate.cxx , > but it seems to me that destroy_workqueue(systemtap_wq) will not be called. > Like https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp > says, please be sure to call destroy_workqueue(systemtap_wq) when stap_init_module() > returns an error after alloc_workqueue() succeeded. The stap_init_module is generated by the stap translator, but it doesn't call destroy_workqueue(). The code now calls destroy_workqueue before each of the returns in stap_init_module(). There is a use of the workqueue in systemtap_kernel_module_exit(), so the destroy_workqueue() follows it. The stap_cleanup_module() was simplified as systemtap_wq must be available after the stap_init_module() is successful. -Will > > Also, system_wq is created without WQ_MEM_RECLAIM flag > ( https://elixir.bootlin.com/linux/v6.6/source/kernel/workqueue.c#L6596 ). > If you don't have a reason to create systemtap_wq with WQ_MEM_RECLAIM flag, > use of WQ_MEM_RECLAIM flag is a waste of kernel resource. > --------------Su1ORGbqduP08doMX01rHkXq Content-Type: text/x-patch; charset=UTF-8; name="pr30831_revision.patch" Content-Disposition: attachment; filename="pr30831_revision.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3J1bnRpbWUvbGludXgvcnVudGltZS5oIGIvcnVudGltZS9saW51eC9ydW50 aW1lLmgKaW5kZXggYTU4NDA3OTRhLi5kNTAxZjc5OTAgMTAwNjQ0Ci0tLSBhL3J1bnRpbWUvbGlu dXgvcnVudGltZS5oCisrKyBiL3J1bnRpbWUvbGludXgvcnVudGltZS5oCkBAIC00MzQsMTUgKzQz NCwxOSBAQCBzdGF0aWMgaW50IHN0YXBfaW5pdF9tb2R1bGUgKHZvaWQpCiAgICAgIG1hcCBoYXNo LiAqLwogICBnZXRfcmFuZG9tX2J5dGVzKCZzdGFwX2hhc2hfc2VlZCwgc2l6ZW9mIChzdGFwX2hh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