From owner-dev-commits-src-all@freebsd.org Mon Jan 18 21:19:51 2021 Return-Path: Delivered-To: dev-commits-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 3026C4F5F89; Mon, 18 Jan 2021 21:19:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKPnL6dd4z3G63; Mon, 18 Jan 2021 21:19:50 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 10ILJgo4048490 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 18 Jan 2021 23:19:45 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 10ILJgo4048490 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 10ILJgF8048489; Mon, 18 Jan 2021 23:19:42 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 18 Jan 2021 23:19:42 +0200 From: Konstantin Belousov To: "Alexander V. Chernikov" Cc: Konstantin Belousov , "src-committers@FreeBSD.org" , "dev-commits-src-all@FreeBSD.org" , "dev-commits-src-main@FreeBSD.org" Subject: Re: git: 3b15beb30b3b - main - Implement malloc_domainset_aligned(9). Message-ID: References: <202101171729.10HHTsHk099908@gitrepo.freebsd.org> <124361611001207@mail.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <124361611001207@mail.yandex.ru> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4DKPnL6dd4z3G63 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2021 21:19:51 -0000 On Mon, Jan 18, 2021 at 08:45:43PM +0000, Alexander V. Chernikov wrote: > 17.01.2021, 17:30, "Konstantin Belousov" : > > The branch main has been updated by kib: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3b15beb30b3b4ba17bae3d1d43c8c04ff862bb57 > > > > commit 3b15beb30b3b4ba17bae3d1d43c8c04ff862bb57 > > Author: Konstantin Belousov > > AuthorDate: 2021-01-14 03:59:34 +0000 > > Commit: Konstantin Belousov > > CommitDate: 2021-01-17 17:29:05 +0000 > > > >     Implement malloc_domainset_aligned(9). > Hi Kostik, > > This change makes my vm panic in usb code. No dump, as dumpdev not mounted yet. > > Note: the below lines have been OCR'ed, so there may be some errors. > > Root mount waiting for: CAM usbus0 usbus1 > panic: malloc_domainset_aligned: result not aligned 0xfffff8000551ca80 size 0x180 align 0x100 Try this. diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 232472708b9b..7c4cb0f465b2 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -768,20 +768,25 @@ malloc_domainset_aligned(size_t size, size_t align, struct malloc_type *mtp, struct domainset *ds, int flags) { void *res; + size_t asize; KASSERT(align != 0 && powerof2(align), ("malloc_domainset_aligned: wrong align %#zx size %#zx", align, size)); - KASSERT(align <= kmemzones[nitems(kmemzones) - 2].kz_size, + KASSERT(align <= PAGE_SIZE, ("malloc_domainset_aligned: align %#zx (size %#zx) too large", align, size)); if (size < align) - size = align; - res = malloc_domainset(size, mtp, ds, flags); + asize = align; + else if (!powerof2(size)) + asize = roundup2(size, align); + else + asize = size; + res = malloc_domainset(asize, mtp, ds, flags); KASSERT(res == NULL || ((uintptr_t)res & (align - 1)) == 0, ("malloc_domainset_aligned: result not aligned %p size %#zx " - "align %#zx", res, size, align)); + "allocsize %#zx align %#zx", res, size, asize, align)); return (res); } @@ -1173,7 +1178,7 @@ mallocinit(void *dummy) align = UMA_ALIGN_PTR; if (powerof2(size) && size > sizeof(void *)) - align = size - 1; + align = (size <= PAGE_SIZE ? size : PAGE_SIZE) - 1; for (subzone = 0; subzone < numzones; subzone++) { kmemzones[indx].kz_zone[subzone] = uma_zcreate(name, size,