Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 332A7720B for ; Tue, 15 Nov 2011 17:26:04 +0000 (UTC) Received: (qmail 16522 invoked by uid 500); 15 Nov 2011 17:26:03 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 16467 invoked by uid 500); 15 Nov 2011 17:26:03 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 16452 invoked by uid 99); 15 Nov 2011 17:26:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 17:26:03 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [195.232.224.71] (HELO mailout02.vodafone.com) (195.232.224.71) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 17:25:52 +0000 Received: from mailint02 (localhost [127.0.0.1]) by mailout02 (Postfix) with ESMTP id 0504521428E for ; Tue, 15 Nov 2011 18:25:32 +0100 (CET) Received: from mbbpop-rat01.vodafone.com (mbbpop-rat01.vodafone.com [195.232.244.148]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailint02 (Postfix) with ESMTPS id EE31B21412E for ; Tue, 15 Nov 2011 18:25:31 +0100 (CET) Received: from [145.230.65.198] (unknown [145.230.65.198]) by mbbpop-rat01.vodafone.com (Postfix) with ESMTP id DCD11160057 for ; Tue, 15 Nov 2011 18:25:31 +0100 (CET) Message-ID: <4EC2A08B.10306@vodafone.com> Date: Tue, 15 Nov 2011 18:25:31 +0100 From: =?UTF-8?B?UsO8ZGlnZXIgUGzDvG0=?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.23) Gecko/20110920 SUSE/3.1.15 Thunderbird/3.1.15 MIME-Version: 1.0 To: dev@httpd.apache.org Subject: Fwd: svn commit: r1202257 - in /httpd/httpd/trunk/server/mpm/event: config3.m4 equeue.c equeue.h event.c Content-Type: multipart/alternative; boundary="------------070401070106030405040000" X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------070401070106030405040000 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit -------- Original-Nachricht -------- Betreff: svn commit: r1202257 - in /httpd/httpd/trunk/server/mpm/event: config3.m4 equeue.c equeue.h event.c Datum: Tue, 15 Nov 2011 15:51:04 GMT Von: pquerna@apache.org Author: pquerna Date: Tue Nov 15 15:51:03 2011 New Revision: 1202257 URL: http://svn.apache.org/viewvc?rev=1202257&view=rev Log: Create a new lock free circular queue, and use it in the EventMPM to remove the timeout mutex that was wrapping both timeout queue operations and pollset operations. Added: httpd/httpd/trunk/server/mpm/event/equeue.c (with props) httpd/httpd/trunk/server/mpm/event/equeue.h (with props) Modified: httpd/httpd/trunk/server/mpm/event/config3.m4 httpd/httpd/trunk/server/mpm/event/event.c Added: httpd/httpd/trunk/server/mpm/event/equeue.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/equeue.c?rev=1202257&view=auto ============================================================================== --- httpd/httpd/trunk/server/mpm/event/equeue.c (added) +++ httpd/httpd/trunk/server/mpm/event/equeue.c Tue Nov 15 15:51:03 2011 @@ -0,0 +1,125 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "equeue.h" + +#include +#include + +struct ap_equeue_t { + apr_uint32_t nelem; + apr_size_t elem_size; + uint8_t *bytes; + volatile apr_uint32_t writeCount; + volatile apr_uint32_t readCount; +}; + + +static APR_INLINE apr_uint32_t count_to_index(ap_equeue_t *eq, apr_uint32_t count) +{ + return (count& (eq->nelem - 1)); +} + +static APR_INLINE void* index_to_bytes(ap_equeue_t *eq, apr_uint32_t idx) +{ + apr_size_t offset = idx * eq->elem_size; + return (void*)&eq->bytes[offset]; +} + +static APR_INLINE apr_uint32_t nearest_power(apr_uint32_t num) +{ + apr_uint32_t n = 1; + while (n< num) { + n<<= 1; + } + + return n; +} + +#if 0 +static void dump_queue(ap_equeue_t *eq) +{ + apr_uint32_t i; + + fprintf(stderr, "dumping %p\n", eq); + fprintf(stderr, " nelem: %u\n", eq->nelem); + fprintf(stderr, " esize: %"APR_SIZE_T_FMT"\n", eq->elem_size); + fprintf(stderr, " wcnt: %u\n", eq->writeCount); + fprintf(stderr, " rcnt: %u\n", eq->writeCount); + fprintf(stderr, " bytes: %p\n", eq->bytes); + for (i = 0; i< eq->nelem; i++) { + fprintf(stderr, " [%u] = %p\n", i, index_to_bytes(eq, i)); + } + + fprintf(stderr, "\n"); + fflush(stderr); +} +#endif + +apr_status_t +ap_equeue_create(apr_pool_t *p, apr_uint32_t nelem, apr_size_t elem_size, ap_equeue_t **eqout) +{ + ap_equeue_t *eq; + + *eqout = NULL; + + eq = apr_palloc(p, sizeof(ap_equeue_t)); + eq->bytes = apr_palloc(p, (1 + nelem) * elem_size); + eq->nelem = nearest_power(nelem); Shouldn't that be + eq->nelem = nearest_power(nelem); + eq->bytes = apr_palloc(p, eq->nelem * elem_size); instead? Otherwise we might allocate too few elements. Regards RĂ¼diger --------------070401070106030405040000 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit svn commit: r1202257 - in /httpd/httpd/trunk/server/mpm/event: config3.m4 equeue.c equeue.h event.c

-------- Original-Nachricht --------
Betreff: svn commit: r1202257 - in /httpd/httpd/trunk/server/mpm/event: config3.m4 equeue.c equeue.h event.c
Datum: Tue, 15 Nov 2011 15:51:04 GMT
Von: pquerna@apache.org


svn commit: r1202257 - in /httpd/httpd/trunk/server/mpm/event: config3.m4 equeue.c equeue.h event.c
Author: pquerna
Date: Tue Nov 15 15:51:03 2011
New Revision: 1202257

URL: http://svn.apache.org/viewvc?rev=1202257&view=rev
Log:
Create a new lock free circular queue, and use it in the EventMPM to remove the timeout mutex
that was wrapping both timeout queue operations and pollset operations.

Added:
    httpd/httpd/trunk/server/mpm/event/equeue.c   (with props)
    httpd/httpd/trunk/server/mpm/event/equeue.h   (with props)
Modified:
    httpd/httpd/trunk/server/mpm/event/config3.m4
    httpd/httpd/trunk/server/mpm/event/event.c


Added: httpd/httpd/trunk/server/mpm/event/equeue.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/equeue.c?rev=1202257&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/equeue.c (added)
+++ httpd/httpd/trunk/server/mpm/event/equeue.c Tue Nov 15 15:51:03 2011
@@ -0,0 +1,125 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "equeue.h"
+
+#include <apr_atomic.h>
+#include <sched.h>
+
+struct ap_equeue_t {
+    apr_uint32_t nelem;
+    apr_size_t elem_size;
+    uint8_t *bytes;
+    volatile apr_uint32_t writeCount;
+    volatile apr_uint32_t readCount;
+};
+
+
+static APR_INLINE apr_uint32_t count_to_index(ap_equeue_t *eq, apr_uint32_t count)
+{
+    return (count & (eq->nelem - 1));
+}
+
+static APR_INLINE void* index_to_bytes(ap_equeue_t *eq, apr_uint32_t idx)
+{
+    apr_size_t offset = idx * eq->elem_size;
+    return (void*)&eq->bytes[offset];
+}
+
+static APR_INLINE apr_uint32_t nearest_power(apr_uint32_t num)
+{
+    apr_uint32_t n = 1;
+    while (n < num) {
+        n <<= 1;
+    }
+
+    return n;
+}
+
+#if 0
+static void dump_queue(ap_equeue_t *eq)
+{
+    apr_uint32_t i;
+
+    fprintf(stderr, "dumping %p\n", eq);
+    fprintf(stderr, "  nelem:   %u\n", eq->nelem);
+    fprintf(stderr, "  esize:   %"APR_SIZE_T_FMT"\n", eq->elem_size);
+    fprintf(stderr, "  wcnt:    %u\n", eq->writeCount);
+    fprintf(stderr, "  rcnt:    %u\n", eq->writeCount);
+    fprintf(stderr, "  bytes:   %p\n", eq->bytes);
+    for (i = 0; i < eq->nelem; i++) {
+        fprintf(stderr, "    [%u] = %p\n", i, index_to_bytes(eq, i));
+    }
+
+    fprintf(stderr, "\n");
+    fflush(stderr);
+}
+#endif
+
+apr_status_t
+ap_equeue_create(apr_pool_t *p, apr_uint32_t nelem, apr_size_t elem_size, ap_equeue_t **eqout)
+{
+    ap_equeue_t *eq;
+
+    *eqout = NULL;
+
+    eq = apr_palloc(p, sizeof(ap_equeue_t));
+    eq->bytes = apr_palloc(p, (1 + nelem) * elem_size);
+    eq->nelem = nearest_power(nelem);

Shouldn't that be 

+    eq->nelem = nearest_power(nelem);
+    eq->bytes = apr_palloc(p, eq->nelem * elem_size);


instead? Otherwise we might allocate too few elements.

Regards

RĂ¼diger




--------------070401070106030405040000--