From owner-svn-src-all@freebsd.org Thu Nov 5 12:24:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD699466D77; Thu, 5 Nov 2020 12:24:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CRjPx51Fxz4cq3; Thu, 5 Nov 2020 12:24:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 944DD13BBC; Thu, 5 Nov 2020 12:24:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0A5CObZi037242; Thu, 5 Nov 2020 12:24:37 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0A5CObdK037241; Thu, 5 Nov 2020 12:24:37 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011051224.0A5CObdK037241@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 5 Nov 2020 12:24:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367379 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367379 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2020 12:24:37 -0000 Author: mjg Date: Thu Nov 5 12:24:37 2020 New Revision: 367379 URL: https://svnweb.freebsd.org/changeset/base/367379 Log: poll/select: change selfd_zone into a malloc type On a sample box vmstat -z shows: ITEM SIZE LIMIT USED FREE REQ 64: 64, 0, 1043784, 4367538,3698187229 selfd: 64, 0, 1520, 13726,182729008 But at the same time: vm.uma.selfd.keg.domain.1.pages: 121 vm.uma.selfd.keg.domain.0.pages: 121 Thus 242 pages got pulled even though the malloc zone would likely accomodate the load without using extra memory. Modified: head/sys/kern/sys_generic.c Modified: head/sys/kern/sys_generic.c ============================================================================== --- head/sys/kern/sys_generic.c Thu Nov 5 12:17:50 2020 (r367378) +++ head/sys/kern/sys_generic.c Thu Nov 5 12:24:37 2020 (r367379) @@ -159,7 +159,7 @@ struct selfd { u_int sf_refs; }; -static uma_zone_t selfd_zone; +MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); static struct mtx_pool *mtxpool_select; #ifdef __LP64__ @@ -1691,11 +1691,11 @@ selfdalloc(struct thread *td, void *cookie) stp = td->td_sel; if (stp->st_free1 == NULL) - stp->st_free1 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO); + stp->st_free1 = malloc(sizeof(*stp->st_free1), M_SELFD, M_WAITOK|M_ZERO); stp->st_free1->sf_td = stp; stp->st_free1->sf_cookie = cookie; if (stp->st_free2 == NULL) - stp->st_free2 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO); + stp->st_free2 = malloc(sizeof(*stp->st_free2), M_SELFD, M_WAITOK|M_ZERO); stp->st_free2->sf_td = stp; stp->st_free2->sf_cookie = cookie; } @@ -1713,7 +1713,7 @@ selfdfree(struct seltd *stp, struct selfd *sfp) mtx_unlock(sfp->sf_mtx); } if (refcount_release(&sfp->sf_refs)) - uma_zfree(selfd_zone, sfp); + free(sfp, M_SELFD); } /* Drain the waiters tied to all the selfd belonging the specified selinfo. */ @@ -1827,7 +1827,7 @@ doselwakeup(struct selinfo *sip, int pri) cv_broadcastpri(&stp->st_wait, pri); mtx_unlock(&stp->st_mtx); if (refcount_release(&sfp->sf_refs)) - uma_zfree(selfd_zone, sfp); + free(sfp, M_SELFD); } mtx_unlock(sip->si_mtx); } @@ -1888,9 +1888,9 @@ seltdfini(struct thread *td) if (stp == NULL) return; if (stp->st_free1) - uma_zfree(selfd_zone, stp->st_free1); + free(stp->st_free1, M_SELFD); if (stp->st_free2) - uma_zfree(selfd_zone, stp->st_free2); + free(stp->st_free2, M_SELFD); td->td_sel = NULL; cv_destroy(&stp->st_wait); mtx_destroy(&stp->st_mtx); @@ -1920,8 +1920,6 @@ static void selectinit(void *dummy __unused) { - selfd_zone = uma_zcreate("selfd", sizeof(struct selfd), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, 0); mtxpool_select = mtx_pool_create("select mtxpool", 128, MTX_DEF); }